/* Project: POPS
 * CS 279, Vanderbilt University
 * by: Igor I. Ges, Michael S. Parrish, Mark E. Sakauye
 *
 *  This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.popsGUI.java;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;

import javax.swing.RepaintManager;
import javax.swing.table.*;

import com.popsGUI.java.popsGUIMainMenu;

//import com.popsDB.java.dao.CustomersDao;
//import com.popsDB.java.dao.ItemsDao;
//import com.popsDB.java.dao.OrdereditemsDao;
//import com.popsDB.java.dao.OrdersDao;
import com.popsDB.java.dto.Items;
import com.popsDB.java.dto.Ordereditems;
import com.popsDB.java.dto.Orders;
import com.popsDB.java.dto.Pricesheets;

//import com.popsDB.java.factory.CustomersDaoFactory;
//import com.popsDB.java.factory.ItemsDaoFactory;
//import com.popsDB.java.factory.OrdereditemsDaoFactory;
//import com.popsDB.java.factory.OrdersDaoFactory;

/**
 *
 * @author  __USER__
 */
public class OrderPanel extends javax.swing.JPanel implements Printable {

	/** Creates new form orderPanel */
	public OrderPanel() {
		initComponents();
		getTableDefaults();
		notificationDialog = new com.popsGUI.java.notificationDialog(null,false);
	}

	//GEN-BEGIN:initComponents
	// <editor-fold defaultstate="collapsed" desc="Generated Code">
	private void initComponents() {

		deleteOrder_dialog = new javax.swing.JDialog();
		deleteOrder_dialog_label = new javax.swing.JLabel();
		deleteOrder_dialog_delete_button = new javax.swing.JButton();
		deleteOrder_dialog_cancel_button = new javax.swing.JButton();
		selectCust_dialog_ORDER = new javax.swing.JDialog();
		selectCust_dialog_ORDER_combobox = new javax.swing.JComboBox();
		selectCust_dialog_ORDER_label = new javax.swing.JLabel();
		selectCust_dialog_ORDER_button = new javax.swing.JButton();
		selectCust_dialog_ORDER_error = new javax.swing.JLabel();
		modifyItems_dialog = new javax.swing.JDialog();
		jScrollPane6 = new javax.swing.JScrollPane();
		modifyItems_itemList_table = new javax.swing.JTable();
		modifyItems_itemList_label = new javax.swing.JLabel();
		modifyItems_addNewItem_button = new javax.swing.JButton();
		modifyItems_addSelectedItem_button = new javax.swing.JButton();
		modifyItems_ItemList_combobox = new javax.swing.JComboBox();
		modifyItems_ItemID_label = new javax.swing.JLabel();
		modifyItems_ItemDescription_label = new javax.swing.JLabel();
		modifyItems_PriceSheetSelect_combobox = new javax.swing.JComboBox();
		modifyItems_UnitSelect_comobBox = new javax.swing.JComboBox();
		modifyItems_Quantity_field = new javax.swing.JTextField();
		modifyItems_Price_label = new javax.swing.JLabel();
		modifyItems_total_label = new javax.swing.JLabel();
		modifyLabel_errorMessageLabel = new javax.swing.JLabel();
		mo_ItemName_Label = new javax.swing.JLabel();
		mo_itemID_label = new javax.swing.JLabel();
		mo_description_label = new javax.swing.JLabel();
		mo_pricesheet_label = new javax.swing.JLabel();
		mo_unit_label = new javax.swing.JLabel();
		mo_quantity_label = new javax.swing.JLabel();
		mo_price_label = new javax.swing.JLabel();
		mo_Total_label = new javax.swing.JLabel();
		selectOrder_dialog = new javax.swing.JDialog();
		selectOrder_dialog_label = new javax.swing.JLabel();
		selectOrder_dialog_combobox = new javax.swing.JComboBox();
		selectOrder_dialog_OK_button = new javax.swing.JButton();
		selectOrder_dialog_error = new javax.swing.JLabel();
		selectDriver_dialog = new javax.swing.JDialog();
		selectDriver_dialog_label = new javax.swing.JLabel();
		selectDriver_dialog_combobox = new javax.swing.JComboBox();
		selectDriver_dialog_error = new javax.swing.JLabel();
		selectDriver_dialog_button = new javax.swing.JButton();
		print_dialog = new javax.swing.JDialog();
		pd_yes_button = new javax.swing.JButton();
		pd_no_button = new javax.swing.JButton();
		pd_info_label = new javax.swing.JLabel();
		printPreview_dialog = new javax.swing.JDialog();
		ppd_preview_scrollpane = new javax.swing.JScrollPane();
		ppd_preview_textarea = new javax.swing.JTextArea();
		op_soldToCustID_label = new javax.swing.JLabel();
		op_shipToName_field = new javax.swing.JLabel();
		op_orderID_label = new javax.swing.JLabel();
		op_orderID_field = new javax.swing.JLabel();
		op_driver_label = new javax.swing.JLabel();
		op_routeOrder_label = new javax.swing.JLabel();
		op_routeOrder_field = new javax.swing.JLabel();
		op_shipToName_label = new javax.swing.JLabel();
		op_soldToCustID_field = new javax.swing.JLabel();
		op_shipToAddress_label = new javax.swing.JLabel();
		op_shipToAddress_field1 = new javax.swing.JLabel();
		op_shipToAddress_field2 = new javax.swing.JLabel();
		op_shipToCity_label = new javax.swing.JLabel();
		op_shipToCity_field = new javax.swing.JLabel();
		op_notes_label = new javax.swing.JLabel();
		jScrollPane2 = new javax.swing.JScrollPane();
		op_notes_field = new javax.swing.JTextArea();
		op_enteredBy_label = new javax.swing.JLabel();
		op_shipmentDate_label = new javax.swing.JLabel();
		op_shipmentDate_field = new javax.swing.JLabel();
		op_salespersonCode_label = new javax.swing.JLabel();
		op_paymentTerms_label = new javax.swing.JLabel();
		op_forman_label = new javax.swing.JLabel();
		op_billToCustID_label = new javax.swing.JLabel();
		op_priceSheet_label = new javax.swing.JLabel();
		op_taxAreaCode_label = new javax.swing.JLabel();
		op_taxLiable_label = new javax.swing.JLabel();
		op_shipToState_label = new javax.swing.JLabel();
		op_shipToState_field = new javax.swing.JLabel();
		op_enteredBy_field = new javax.swing.JLabel();
		op_salespersonCode_field = new javax.swing.JLabel();
		op_paymentTerms_field = new javax.swing.JLabel();
		op_foreman_field = new javax.swing.JLabel();
		op_billToCustID_field = new javax.swing.JLabel();
		op_taxAreaCode_field = new javax.swing.JLabel();
		op_taxLiable_field = new javax.swing.JLabel();
		op_priceSheet_combobox = new javax.swing.JComboBox();
		op_directions_label = new javax.swing.JLabel();
		op_directions_field = new javax.swing.JLabel();
		op_numPrinted_label = new javax.swing.JLabel();
		op_numPrinted_field = new javax.swing.JLabel();
		op_entryTime_label = new javax.swing.JLabel();
		op_entryTime_field = new javax.swing.JLabel();
		op_processOrder_button = new javax.swing.JButton();
		op_deleteOrder_button = new javax.swing.JButton();
		op_orderedItems_scrollpane = new javax.swing.JScrollPane();
		op_orderedItems_table = new javax.swing.JTable();
		op_selectCustomer_button = new javax.swing.JButton();
		op_orderedItems_label = new javax.swing.JLabel();
		op_selectOrder_button = new javax.swing.JButton();
		op_modifyItems_button = new javax.swing.JButton();
		op_orderStatus_label = new javax.swing.JLabel();
		op_orderStatus_field = new javax.swing.JLabel();
		op_createOrder_button = new javax.swing.JButton();
		op_driver_field = new javax.swing.JLabel();
		op_deleteOrder_button2 = new javax.swing.JButton();
		op_createOrder_button2 = new javax.swing.JButton();
		op_processOrder_button2 = new javax.swing.JButton();
		op_total_label = new javax.swing.JLabel();
		op_total_field = new javax.swing.JLabel();
		op_print_button = new javax.swing.JButton();

		deleteOrder_dialog.setMinimumSize(new java.awt.Dimension(400, 200));
		deleteOrder_dialog.setModal(true);

		deleteOrder_dialog_label
				.setText("Are you sure you want to delete this order?");

		deleteOrder_dialog_delete_button.setLabel("Delete");
		deleteOrder_dialog_delete_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						deleteOrder_dialog_delete_buttonActionPerformed(evt);
					}
				});

		deleteOrder_dialog_cancel_button.setLabel("Cancel");
		deleteOrder_dialog_cancel_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						deleteOrder_dialog_cancel_buttonActionPerformed(evt);
					}
				});

		javax.swing.GroupLayout deleteOrder_dialogLayout = new javax.swing.GroupLayout(
				deleteOrder_dialog.getContentPane());
		deleteOrder_dialog.getContentPane().setLayout(deleteOrder_dialogLayout);
		deleteOrder_dialogLayout
				.setHorizontalGroup(deleteOrder_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								deleteOrder_dialogLayout
										.createSequentialGroup()
										.addGap(70, 70, 70)
										.addGroup(
												deleteOrder_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING,
																false)
														.addGroup(
																deleteOrder_dialogLayout
																		.createSequentialGroup()
																		.addComponent(
																				deleteOrder_dialog_delete_button)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				Short.MAX_VALUE)
																		.addComponent(
																				deleteOrder_dialog_cancel_button))
														.addComponent(
																deleteOrder_dialog_label))
										.addContainerGap(60, Short.MAX_VALUE)));
		deleteOrder_dialogLayout
				.setVerticalGroup(deleteOrder_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								deleteOrder_dialogLayout
										.createSequentialGroup()
										.addGap(45, 45, 45)
										.addComponent(deleteOrder_dialog_label)
										.addGap(30, 30, 30)
										.addGroup(
												deleteOrder_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																deleteOrder_dialog_delete_button)
														.addComponent(
																deleteOrder_dialog_cancel_button))
										.addContainerGap(38, Short.MAX_VALUE)));

		selectCust_dialog_ORDER
				.setMinimumSize(new java.awt.Dimension(350, 220));

		selectCust_dialog_ORDER_combobox
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						selectCust_dialog_ORDER_comboboxActionPerformed(evt);
					}
				});

		selectCust_dialog_ORDER_label
				.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		selectCust_dialog_ORDER_label.setText("Select Customer");

		selectCust_dialog_ORDER_button.setText("OK");
		selectCust_dialog_ORDER_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						selectCust_dialog_ORDER_buttonActionPerformed(evt);
					}
				});

		javax.swing.GroupLayout selectCust_dialog_ORDERLayout = new javax.swing.GroupLayout(
				selectCust_dialog_ORDER.getContentPane());
		selectCust_dialog_ORDER.getContentPane().setLayout(
				selectCust_dialog_ORDERLayout);
		selectCust_dialog_ORDERLayout
				.setHorizontalGroup(selectCust_dialog_ORDERLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								selectCust_dialog_ORDERLayout
										.createSequentialGroup()
										.addGroup(
												selectCust_dialog_ORDERLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addGroup(
																selectCust_dialog_ORDERLayout
																		.createSequentialGroup()
																		.addGap(
																				52,
																				52,
																				52)
																		.addGroup(
																				selectCust_dialog_ORDERLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING,
																								false)
																						.addComponent(
																								selectCust_dialog_ORDER_label,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								selectCust_dialog_ORDER_combobox,
																								javax.swing.GroupLayout.PREFERRED_SIZE,
																								227,
																								javax.swing.GroupLayout.PREFERRED_SIZE)))
														.addGroup(
																selectCust_dialog_ORDERLayout
																		.createSequentialGroup()
																		.addGap(
																				146,
																				146,
																				146)
																		.addComponent(
																				selectCust_dialog_ORDER_button))
														.addGroup(
																javax.swing.GroupLayout.Alignment.TRAILING,
																selectCust_dialog_ORDERLayout
																		.createSequentialGroup()
																		.addContainerGap()
																		.addComponent(
																				selectCust_dialog_ORDER_error,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				316,
																				Short.MAX_VALUE)))
										.addContainerGap()));
		selectCust_dialog_ORDERLayout
				.setVerticalGroup(selectCust_dialog_ORDERLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								selectCust_dialog_ORDERLayout
										.createSequentialGroup()
										.addGap(38, 38, 38)
										.addComponent(
												selectCust_dialog_ORDER_label)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												selectCust_dialog_ORDER_combobox,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
										.addComponent(
												selectCust_dialog_ORDER_error,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												34, Short.MAX_VALUE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												selectCust_dialog_ORDER_button)
										.addGap(34, 34, 34)));

		modifyItems_dialog.setMinimumSize(new java.awt.Dimension(1000, 600));

		modifyItems_itemList_table
				.setModel(new javax.swing.table.DefaultTableModel(
						new Object[][] {
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null } }, new String[] { "Item ID",
								"Item Name", "Description", "Quantity", "Unit",
								"Unit Price", "Amt. Excl. Sales Tax" }) {
					Class[] types = new Class[] { java.lang.Integer.class,
							java.lang.String.class, java.lang.String.class,
							java.lang.Integer.class, java.lang.String.class,
							java.lang.Float.class, java.lang.Float.class };
					boolean[] canEdit = new boolean[] { false, false, false,
							true, false, false, false };

					public Class getColumnClass(int columnIndex) {
						return types[columnIndex];
					}

					public boolean isCellEditable(int rowIndex, int columnIndex) {
						return canEdit[columnIndex];
					}
				});
		modifyItems_itemList_table
				.addFocusListener(new java.awt.event.FocusAdapter() {
					public void focusLost(java.awt.event.FocusEvent evt) {
						modifyItems_itemList_tableFocusLost(evt);
					}
				});
		jScrollPane6.setViewportView(modifyItems_itemList_table);

		modifyItems_itemList_label
				.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		modifyItems_itemList_label.setText("Item List");

		modifyItems_addNewItem_button.setText("Add New Item");
		modifyItems_addNewItem_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						modifyItems_addNewItem_buttonActionPerformed(evt);
					}
				});

		modifyItems_addSelectedItem_button.setText("Confirm Modifications");
		modifyItems_addSelectedItem_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						modifyItems_addSelectedItem_buttonActionPerformed(evt);
					}
				});

		modifyItems_ItemList_combobox
				.setToolTipText("Select Item that you want to add here");
		modifyItems_ItemList_combobox
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						modifyItems_ItemList_comboboxActionPerformed(evt);
					}
				});

		modifyItems_ItemID_label.setText("itemID");
		modifyItems_ItemID_label.setToolTipText("itemID");

		modifyItems_ItemDescription_label.setText("Description");
		modifyItems_ItemDescription_label.setToolTipText("Description");

		modifyItems_PriceSheetSelect_combobox.setToolTipText("PriceGroup");
		modifyItems_PriceSheetSelect_combobox
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						modifyItems_PriceSheetSelect_comboboxActionPerformed(evt);
					}
				});

		modifyItems_UnitSelect_comobBox.setToolTipText("units");
		modifyItems_UnitSelect_comobBox
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						modifyItems_UnitSelect_comobBoxActionPerformed(evt);
					}
				});

		modifyItems_Quantity_field.setToolTipText("Quantity");
		modifyItems_Quantity_field
				.addCaretListener(new javax.swing.event.CaretListener() {
					public void caretUpdate(javax.swing.event.CaretEvent evt) {
						modifyItems_Quantity_fieldCaretUpdate(evt);
					}
				});

		modifyItems_Price_label.setText("Price");
		modifyItems_Price_label.setToolTipText("Price");

		modifyItems_total_label.setText("Total");
		modifyItems_total_label.setToolTipText("Total");

		modifyLabel_errorMessageLabel.setMinimumSize(new java.awt.Dimension(
				356, 16));

		mo_ItemName_Label.setText("Item Name");

		mo_itemID_label.setText("Item ID");

		mo_description_label.setText("Description");

		mo_pricesheet_label.setText("Price Sheet");

		mo_unit_label.setText("Unit");

		mo_quantity_label.setText("Quantity");

		mo_price_label.setText("Price ($)");

		mo_Total_label.setText("Total ($)");

		javax.swing.GroupLayout modifyItems_dialogLayout = new javax.swing.GroupLayout(
				modifyItems_dialog.getContentPane());
		modifyItems_dialog.getContentPane().setLayout(modifyItems_dialogLayout);
		modifyItems_dialogLayout
				.setHorizontalGroup(modifyItems_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								modifyItems_dialogLayout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												modifyItems_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addComponent(
																modifyItems_itemList_label,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																954,
																Short.MAX_VALUE)
														.addComponent(
																jScrollPane6,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																954,
																Short.MAX_VALUE)
														.addGroup(
																javax.swing.GroupLayout.Alignment.TRAILING,
																modifyItems_dialogLayout
																		.createSequentialGroup()
																		.addComponent(
																				modifyItems_addNewItem_button)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
																		.addComponent(
																				modifyLabel_errorMessageLabel,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				675,
																				Short.MAX_VALUE)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				modifyItems_addSelectedItem_button))
														.addGroup(
																modifyItems_dialogLayout
																		.createSequentialGroup()
																		.addGroup(
																				modifyItems_dialogLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addComponent(
																								mo_ItemName_Label)
																						.addComponent(
																								modifyItems_ItemList_combobox,
																								javax.swing.GroupLayout.PREFERRED_SIZE,
																								126,
																								javax.swing.GroupLayout.PREFERRED_SIZE))
																		.addGap(
																				18,
																				18,
																				18)
																		.addGroup(
																				modifyItems_dialogLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addGroup(
																								modifyItems_dialogLayout
																										.createSequentialGroup()
																										.addComponent(
																												mo_itemID_label)
																										.addPreferredGap(
																												javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
																										.addComponent(
																												mo_description_label))
																						.addGroup(
																								modifyItems_dialogLayout
																										.createSequentialGroup()
																										.addComponent(
																												modifyItems_ItemID_label)
																										.addPreferredGap(
																												javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
																										.addComponent(
																												modifyItems_ItemDescription_label,
																												javax.swing.GroupLayout.PREFERRED_SIZE,
																												221,
																												javax.swing.GroupLayout.PREFERRED_SIZE)))
																		.addGap(
																				18,
																				18,
																				18)
																		.addGroup(
																				modifyItems_dialogLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addComponent(
																								modifyItems_PriceSheetSelect_combobox,
																								javax.swing.GroupLayout.PREFERRED_SIZE,
																								121,
																								javax.swing.GroupLayout.PREFERRED_SIZE)
																						.addComponent(
																								mo_pricesheet_label))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				modifyItems_dialogLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addComponent(
																								modifyItems_UnitSelect_comobBox,
																								javax.swing.GroupLayout.PREFERRED_SIZE,
																								112,
																								javax.swing.GroupLayout.PREFERRED_SIZE)
																						.addComponent(
																								mo_unit_label))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				modifyItems_dialogLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addComponent(
																								mo_quantity_label)
																						.addComponent(
																								modifyItems_Quantity_field,
																								javax.swing.GroupLayout.PREFERRED_SIZE,
																								60,
																								javax.swing.GroupLayout.PREFERRED_SIZE))
																		.addGap(
																				18,
																				18,
																				18)
																		.addGroup(
																				modifyItems_dialogLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addComponent(
																								mo_price_label,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								108,
																								Short.MAX_VALUE)
																						.addComponent(
																								modifyItems_Price_label,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								108,
																								Short.MAX_VALUE))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				modifyItems_dialogLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.TRAILING,
																								false)
																						.addGroup(
																								modifyItems_dialogLayout
																										.createSequentialGroup()
																										.addComponent(
																												mo_Total_label,
																												javax.swing.GroupLayout.PREFERRED_SIZE,
																												69,
																												javax.swing.GroupLayout.PREFERRED_SIZE)
																										.addGap(
																												11,
																												11,
																												11))
																						.addGroup(
																								modifyItems_dialogLayout
																										.createSequentialGroup()
																										.addComponent(
																												modifyItems_total_label,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												Short.MAX_VALUE)
																										.addPreferredGap(
																												javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
																		.addGap(
																				4,
																				4,
																				4)))
										.addContainerGap()));
		modifyItems_dialogLayout
				.setVerticalGroup(modifyItems_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								modifyItems_dialogLayout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(
												modifyItems_itemList_label)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												jScrollPane6,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												362,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												modifyItems_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addComponent(
																mo_price_label)
														.addGroup(
																modifyItems_dialogLayout
																		.createSequentialGroup()
																		.addGroup(
																				modifyItems_dialogLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addGroup(
																								modifyItems_dialogLayout
																										.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.TRAILING)
																										.addGroup(
																												modifyItems_dialogLayout
																														.createSequentialGroup()
																														.addComponent(
																																mo_ItemName_Label)
																														.addGap(
																																28,
																																28,
																																28))
																										.addGroup(
																												modifyItems_dialogLayout
																														.createSequentialGroup()
																														.addGroup(
																																modifyItems_dialogLayout
																																		.createParallelGroup(
																																				javax.swing.GroupLayout.Alignment.BASELINE)
																																		.addComponent(
																																				mo_itemID_label)
																																		.addComponent(
																																				mo_description_label))
																														.addGap(
																																23,
																																23,
																																23))
																										.addGroup(
																												modifyItems_dialogLayout
																														.createSequentialGroup()
																														.addComponent(
																																mo_pricesheet_label)
																														.addPreferredGap(
																																javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																														.addGroup(
																																modifyItems_dialogLayout
																																		.createParallelGroup(
																																				javax.swing.GroupLayout.Alignment.BASELINE)
																																		.addComponent(
																																				modifyItems_PriceSheetSelect_combobox,
																																				javax.swing.GroupLayout.PREFERRED_SIZE,
																																				javax.swing.GroupLayout.DEFAULT_SIZE,
																																				javax.swing.GroupLayout.PREFERRED_SIZE)
																																		.addComponent(
																																				modifyItems_ItemID_label)
																																		.addComponent(
																																				modifyItems_ItemList_combobox,
																																				javax.swing.GroupLayout.PREFERRED_SIZE,
																																				javax.swing.GroupLayout.DEFAULT_SIZE,
																																				javax.swing.GroupLayout.PREFERRED_SIZE)
																																		.addComponent(
																																				modifyItems_ItemDescription_label)))
																										.addGroup(
																												modifyItems_dialogLayout
																														.createSequentialGroup()
																														.addComponent(
																																mo_unit_label)
																														.addPreferredGap(
																																javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																														.addComponent(
																																modifyItems_UnitSelect_comobBox,
																																javax.swing.GroupLayout.PREFERRED_SIZE,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																javax.swing.GroupLayout.PREFERRED_SIZE))
																										.addGroup(
																												modifyItems_dialogLayout
																														.createSequentialGroup()
																														.addComponent(
																																mo_quantity_label)
																														.addGap(
																																5,
																																5,
																																5)
																														.addGroup(
																																modifyItems_dialogLayout
																																		.createParallelGroup(
																																				javax.swing.GroupLayout.Alignment.BASELINE)
																																		.addComponent(
																																				modifyItems_Quantity_field,
																																				javax.swing.GroupLayout.PREFERRED_SIZE,
																																				javax.swing.GroupLayout.DEFAULT_SIZE,
																																				javax.swing.GroupLayout.PREFERRED_SIZE)
																																		.addComponent(
																																				modifyItems_Price_label))
																														.addGap(
																																2,
																																2,
																																2)))
																						.addGroup(
																								modifyItems_dialogLayout
																										.createSequentialGroup()
																										.addComponent(
																												mo_Total_label)
																										.addPreferredGap(
																												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																										.addComponent(
																												modifyItems_total_label)))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				modifyItems_dialogLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addComponent(
																								modifyItems_addNewItem_button)
																						.addGroup(
																								modifyItems_dialogLayout
																										.createSequentialGroup()
																										.addGap(
																												5,
																												5,
																												5)
																										.addGroup(
																												modifyItems_dialogLayout
																														.createParallelGroup(
																																javax.swing.GroupLayout.Alignment.TRAILING)
																														.addComponent(
																																modifyItems_addSelectedItem_button)
																														.addComponent(
																																modifyLabel_errorMessageLabel,
																																javax.swing.GroupLayout.PREFERRED_SIZE,
																																21,
																																javax.swing.GroupLayout.PREFERRED_SIZE))))))
										.addContainerGap()));

		selectOrder_dialog.setMinimumSize(new java.awt.Dimension(500, 300));

		selectOrder_dialog_label
				.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		selectOrder_dialog_label.setText("Select Order ID");

		selectOrder_dialog_combobox.setPreferredSize(new java.awt.Dimension(
				400, 400));

		selectOrder_dialog_OK_button.setText("OK");
		selectOrder_dialog_OK_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						selectOrder_dialog_OK_buttonActionPerformed(evt);
					}
				});

		javax.swing.GroupLayout selectOrder_dialogLayout = new javax.swing.GroupLayout(
				selectOrder_dialog.getContentPane());
		selectOrder_dialog.getContentPane().setLayout(selectOrder_dialogLayout);
		selectOrder_dialogLayout
				.setHorizontalGroup(selectOrder_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								selectOrder_dialogLayout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(
												selectOrder_dialog_error,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												355, Short.MAX_VALUE).addGap(
												35, 35, 35))
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								selectOrder_dialogLayout
										.createSequentialGroup()
										.addGap(45, 45, 45)
										.addGroup(
												selectOrder_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING)
														.addComponent(
																selectOrder_dialog_label,
																javax.swing.GroupLayout.Alignment.LEADING,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																290,
																Short.MAX_VALUE)
														.addComponent(
																selectOrder_dialog_combobox,
																javax.swing.GroupLayout.Alignment.LEADING,
																0, 290,
																Short.MAX_VALUE))
										.addGap(67, 67, 67))
						.addGroup(
								selectOrder_dialogLayout
										.createSequentialGroup()
										.addGap(155, 155, 155)
										.addComponent(
												selectOrder_dialog_OK_button,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												74,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addContainerGap(173, Short.MAX_VALUE)));
		selectOrder_dialogLayout
				.setVerticalGroup(selectOrder_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								selectOrder_dialogLayout
										.createSequentialGroup()
										.addGap(32, 32, 32)
										.addComponent(selectOrder_dialog_label)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												selectOrder_dialog_combobox,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												32,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addGap(31, 31, 31)
										.addComponent(
												selectOrder_dialog_error,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												60,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED,
												32, Short.MAX_VALUE)
										.addComponent(
												selectOrder_dialog_OK_button,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												40,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addContainerGap()));

		selectDriver_dialog.setMinimumSize(new java.awt.Dimension(400, 300));

		selectDriver_dialog_label
				.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		selectDriver_dialog_label.setText("Select Driver");

		selectDriver_dialog_button.setText("OK");
		selectDriver_dialog_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						selectDriver_dialog_buttonActionPerformed(evt);
					}
				});

		javax.swing.GroupLayout selectDriver_dialogLayout = new javax.swing.GroupLayout(
				selectDriver_dialog.getContentPane());
		selectDriver_dialog.getContentPane().setLayout(
				selectDriver_dialogLayout);
		selectDriver_dialogLayout
				.setHorizontalGroup(selectDriver_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								selectDriver_dialogLayout
										.createSequentialGroup()
										.addGroup(
												selectDriver_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addGroup(
																selectDriver_dialogLayout
																		.createSequentialGroup()
																		.addContainerGap()
																		.addGroup(
																				selectDriver_dialogLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.TRAILING)
																						.addComponent(
																								selectDriver_dialog_combobox,
																								javax.swing.GroupLayout.Alignment.LEADING,
																								0,
																								376,
																								Short.MAX_VALUE)
																						.addComponent(
																								selectDriver_dialog_label,
																								javax.swing.GroupLayout.Alignment.LEADING,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								376,
																								Short.MAX_VALUE)))
														.addGroup(
																selectDriver_dialogLayout
																		.createSequentialGroup()
																		.addGap(
																				156,
																				156,
																				156)
																		.addComponent(
																				selectDriver_dialog_button,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				92,
																				javax.swing.GroupLayout.PREFERRED_SIZE))
														.addGroup(
																selectDriver_dialogLayout
																		.createSequentialGroup()
																		.addContainerGap()
																		.addComponent(
																				selectDriver_dialog_error,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				376,
																				Short.MAX_VALUE)))
										.addContainerGap()));
		selectDriver_dialogLayout
				.setVerticalGroup(selectDriver_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								selectDriver_dialogLayout
										.createSequentialGroup()
										.addGap(31, 31, 31)
										.addComponent(selectDriver_dialog_label)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												selectDriver_dialog_combobox,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												32,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED,
												58, Short.MAX_VALUE)
										.addComponent(
												selectDriver_dialog_error,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												54,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addGap(53, 53, 53)
										.addComponent(
												selectDriver_dialog_button,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												36,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addContainerGap()));

		print_dialog.setMinimumSize(new java.awt.Dimension(400, 300));

		pd_yes_button.setText("Yes");
		pd_yes_button.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				pd_yes_buttonActionPerformed(evt);
			}
		});

		pd_no_button.setText("No");
		pd_no_button.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				pd_no_buttonActionPerformed(evt);
			}
		});

		pd_info_label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

		javax.swing.GroupLayout print_dialogLayout = new javax.swing.GroupLayout(
				print_dialog.getContentPane());
		print_dialog.getContentPane().setLayout(print_dialogLayout);
		print_dialogLayout
				.setHorizontalGroup(print_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								print_dialogLayout
										.createSequentialGroup()
										.addGroup(
												print_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addGroup(
																print_dialogLayout
																		.createSequentialGroup()
																		.addContainerGap()
																		.addComponent(
																				pd_info_label,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				376,
																				Short.MAX_VALUE))
														.addGroup(
																print_dialogLayout
																		.createSequentialGroup()
																		.addGap(
																				114,
																				114,
																				114)
																		.addComponent(
																				pd_yes_button)
																		.addGap(
																				61,
																				61,
																				61)
																		.addComponent(
																				pd_no_button)))
										.addContainerGap()));

		print_dialogLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
				new java.awt.Component[] { pd_no_button, pd_yes_button });

		print_dialogLayout
				.setVerticalGroup(print_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								print_dialogLayout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(
												pd_info_label,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												220,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												print_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																pd_yes_button)
														.addComponent(
																pd_no_button))
										.addContainerGap(35, Short.MAX_VALUE)));

		ppd_preview_textarea.setColumns(20);
		ppd_preview_textarea.setRows(5);
		ppd_preview_scrollpane.setViewportView(ppd_preview_textarea);

		javax.swing.GroupLayout printPreview_dialogLayout = new javax.swing.GroupLayout(
				printPreview_dialog.getContentPane());
		printPreview_dialog.getContentPane().setLayout(
				printPreview_dialogLayout);
		printPreview_dialogLayout
				.setHorizontalGroup(printPreview_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								printPreview_dialogLayout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(
												ppd_preview_scrollpane,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												376, Short.MAX_VALUE)
										.addContainerGap()));
		printPreview_dialogLayout
				.setVerticalGroup(printPreview_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								printPreview_dialogLayout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(
												ppd_preview_scrollpane,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												274, Short.MAX_VALUE)
										.addContainerGap()));

		setPreferredSize(new java.awt.Dimension(1024, 679));

		op_soldToCustID_label
				.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
		op_soldToCustID_label.setText("Sold-To Customer ID:");

		op_shipToName_field.setText("Customer Name");

		op_orderID_label
				.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
		op_orderID_label.setText("Order ID:");

		op_orderID_field.setText("0000000");

		op_driver_label
				.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
		op_driver_label.setText("Driver:");

		op_routeOrder_label
				.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
		op_routeOrder_label.setText("Route Order:");

		op_routeOrder_field.setText("Route Order...");

		op_shipToName_label
				.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
		op_shipToName_label.setText("Ship-To Name:");

		op_soldToCustID_field.setText("0000000");

		op_shipToAddress_label
				.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
		op_shipToAddress_label.setText("Ship-To Address:");

		op_shipToAddress_field1.setText("Address Line 1");

		op_shipToAddress_field2.setText("Address Line 2");

		op_shipToCity_label
				.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
		op_shipToCity_label.setText("Ship-To City:");

		op_shipToCity_field.setText("City");

		op_notes_label.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
		op_notes_label.setText("Notes:");

		op_notes_field.setColumns(20);
		op_notes_field.setRows(5);
		op_notes_field.setToolTipText("The notes are at most 160 symbols long");
		jScrollPane2.setViewportView(op_notes_field);

		op_enteredBy_label
				.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
		op_enteredBy_label.setText("Entered By:");

		op_shipmentDate_label
				.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
		op_shipmentDate_label.setText("Shipment Date:");

		op_shipmentDate_field.setText("02/10/10");

		op_salespersonCode_label
				.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
		op_salespersonCode_label.setText("Salesperson Code:");

		op_paymentTerms_label
				.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
		op_paymentTerms_label.setText("Payment Terms:");

		op_forman_label
				.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
		op_forman_label.setText("Foreman:");

		op_billToCustID_label
				.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
		op_billToCustID_label.setText("Bill-To Customer ID:");

		op_priceSheet_label
				.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
		op_priceSheet_label.setText("Price Sheet:");

		op_taxAreaCode_label
				.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
		op_taxAreaCode_label.setText("Tax Area Code:");

		op_taxLiable_label
				.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
		op_taxLiable_label.setText("Tax Liable:");

		op_shipToState_label.setText("Ship-To State:");

		op_shipToState_field.setText("State");

		op_enteredBy_field.setText("Name");

		op_salespersonCode_field.setText("Code");

		op_paymentTerms_field.setText("C.O.D.");

		op_foreman_field.setText("Name");

		op_billToCustID_field.setText("0000000");

		op_taxAreaCode_field.setText("TN SALES TAX");

		op_taxLiable_field.setText("N");

		op_directions_label.setText("Directions:");

		op_directions_field.setText("directions...");
		op_directions_field
				.setVerticalAlignment(javax.swing.SwingConstants.TOP);

		op_numPrinted_label.setText("Number Printed:");

		op_numPrinted_field.setText("0");

		op_entryTime_label.setText("Entry Time:");

		op_entryTime_field.setText("02/10/10");

		op_processOrder_button.setText("Process Order");
		op_processOrder_button.setAlignmentY(0.0F);
		op_processOrder_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						op_processOrder_buttonActionPerformed(evt);
					}
				});

		op_deleteOrder_button.setText("Delete Order");
		op_deleteOrder_button.setAlignmentY(0.0F);
		op_deleteOrder_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						op_deleteOrder_buttonActionPerformed(evt);
					}
				});

		op_orderedItems_table
				.setModel(new javax.swing.table.DefaultTableModel(
						new Object[][] {
								{ new Integer(0), "", null, null, null, null,
										null },
								{ new Integer(0), "", null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null },
								{ new Integer(0), null, null, null, null, null,
										null } }, new String[] { "ItemID",
								"ItemName", "Description", "Unit", "Quantity",
								"ItemPrice", "Subtotal" }) {
					Class[] types = new Class[] { java.lang.Integer.class,
							java.lang.String.class, java.lang.String.class,
							java.lang.String.class, java.lang.Integer.class,
							java.lang.Float.class, java.lang.Float.class };
					boolean[] canEdit = new boolean[] { false, false, false,
							false, false, false, false };

					public Class getColumnClass(int columnIndex) {
						return types[columnIndex];
					}

					public boolean isCellEditable(int rowIndex, int columnIndex) {
						return canEdit[columnIndex];
					}
				});
		op_orderedItems_scrollpane.setViewportView(op_orderedItems_table);

		op_selectCustomer_button.setText(". . .");
		op_selectCustomer_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						op_selectCustomer_buttonActionPerformed(evt);
					}
				});

		op_orderedItems_label.setText("Ordered Items");

		op_selectOrder_button.setText(". . .");
		op_selectOrder_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						op_selectOrder_buttonActionPerformed(evt);
					}
				});

		op_modifyItems_button.setText("Modify Items");
		op_modifyItems_button.setAlignmentX(5.0F);
		op_modifyItems_button.setAlignmentY(0.0F);
		op_modifyItems_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						op_modifyItems_buttonActionPerformed(evt);
					}
				});

		op_orderStatus_label.setText("Order Status");

		op_orderStatus_field.setText("None");

		op_createOrder_button.setText("Create/Save Order");
		op_createOrder_button.setAlignmentY(0.0F);
		op_createOrder_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						op_createOrder_buttonActionPerformed(evt);
					}
				});

		op_driver_field.setText("Name");

		op_deleteOrder_button2.setText("Delete Order");
		op_deleteOrder_button2
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						op_deleteOrder_buttonActionPerformed(evt);
					}
				});

		op_createOrder_button2.setText("Create/Save Order");
		op_createOrder_button2
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						op_createOrder_buttonActionPerformed(evt);
					}
				});

		op_processOrder_button2.setText("Process Order");
		op_processOrder_button2
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						op_processOrder_buttonActionPerformed(evt);
					}
				});

		op_total_label.setFont(new java.awt.Font("Segoe UI", 0, 18));
		op_total_label.setText("Total($):");

		op_total_field.setFont(new java.awt.Font("Segoe UI", 0, 18));
		op_total_field.setText("0");

		op_print_button.setText("Print Order");
		op_print_button.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				op_print_buttonActionPerformed(evt);
			}
		});

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
		this.setLayout(layout);
		layout
				.setHorizontalGroup(layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								layout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING)
														.addComponent(
																op_processOrder_button)
														.addComponent(
																op_directions_label)
														.addGroup(
																layout
																		.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.TRAILING,
																				false)
																		.addComponent(
																				op_shipToState_label)
																		.addComponent(
																				op_notes_label,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				51,
																				javax.swing.GroupLayout.PREFERRED_SIZE)
																		.addGroup(
																				layout
																						.createSequentialGroup()
																						.addGap(
																								2,
																								2,
																								2)
																						.addComponent(
																								op_orderID_label))
																		.addComponent(
																				op_routeOrder_label,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				110,
																				javax.swing.GroupLayout.PREFERRED_SIZE)
																		.addComponent(
																				op_shipToCity_label,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				Short.MAX_VALUE)
																		.addComponent(
																				op_shipToAddress_label,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				Short.MAX_VALUE)
																		.addComponent(
																				op_shipToName_label,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				Short.MAX_VALUE)
																		.addComponent(
																				op_soldToCustID_label,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				Short.MAX_VALUE)
																		.addComponent(
																				op_driver_label))
														.addComponent(
																op_numPrinted_label)
														.addComponent(
																op_entryTime_label)
														.addComponent(
																op_enteredBy_label,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																150,
																Short.MAX_VALUE)
														.addComponent(
																op_shipmentDate_label,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																150,
																Short.MAX_VALUE)
														.addComponent(
																op_salespersonCode_label,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																150,
																Short.MAX_VALUE)
														.addComponent(
																op_paymentTerms_label,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																150,
																Short.MAX_VALUE)
														.addComponent(
																op_forman_label,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																150,
																Short.MAX_VALUE)
														.addComponent(
																op_billToCustID_label)
														.addComponent(
																op_priceSheet_label,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																150,
																Short.MAX_VALUE)
														.addComponent(
																op_taxAreaCode_label,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																150,
																Short.MAX_VALUE)
														.addComponent(
																op_orderStatus_label))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addComponent(
																op_driver_field)
														.addComponent(
																op_orderStatus_field)
														.addGroup(
																layout
																		.createSequentialGroup()
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addGroup(
																								layout
																										.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.LEADING,
																												false)
																										.addComponent(
																												op_directions_field,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												Short.MAX_VALUE)
																										.addComponent(
																												op_orderID_field,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												Short.MAX_VALUE)
																										.addComponent(
																												op_shipToState_field,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												Short.MAX_VALUE)
																										.addComponent(
																												jScrollPane2,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												213,
																												Short.MAX_VALUE)
																										.addComponent(
																												op_shipToCity_field,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												Short.MAX_VALUE)
																										.addComponent(
																												op_shipToAddress_field2,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												Short.MAX_VALUE)
																										.addComponent(
																												op_shipToAddress_field1,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												Short.MAX_VALUE)
																										.addComponent(
																												op_shipToName_field,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												Short.MAX_VALUE)
																										.addComponent(
																												op_soldToCustID_field,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												Short.MAX_VALUE)
																										.addComponent(
																												op_routeOrder_field))
																						.addComponent(
																								op_enteredBy_field)
																						.addComponent(
																								op_shipmentDate_field)
																						.addComponent(
																								op_salespersonCode_field)
																						.addComponent(
																								op_numPrinted_field)
																						.addComponent(
																								op_entryTime_field))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addComponent(
																								op_selectOrder_button)
																						.addComponent(
																								op_selectCustomer_button)))
														.addComponent(
																op_paymentTerms_field)
														.addComponent(
																op_foreman_field)
														.addComponent(
																op_billToCustID_field)
														.addGroup(
																layout
																		.createSequentialGroup()
																		.addComponent(
																				op_deleteOrder_button)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
																		.addComponent(
																				op_createOrder_button))
														.addGroup(
																layout
																		.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.TRAILING)
																		.addGroup(
																				javax.swing.GroupLayout.Alignment.LEADING,
																				layout
																						.createSequentialGroup()
																						.addComponent(
																								op_taxAreaCode_field)
																						.addPreferredGap(
																								javax.swing.LayoutStyle.ComponentPlacement.RELATED,
																								142,
																								Short.MAX_VALUE)
																						.addComponent(
																								op_taxLiable_label)
																						.addPreferredGap(
																								javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																						.addComponent(
																								op_taxLiable_field))
																		.addComponent(
																				op_priceSheet_combobox,
																				javax.swing.GroupLayout.Alignment.LEADING,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				170,
																				javax.swing.GroupLayout.PREFERRED_SIZE)))
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addGroup(
																layout
																		.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.LEADING)
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.TRAILING)
																						.addGroup(
																								layout
																										.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.LEADING)
																										.addGroup(
																												layout
																														.createSequentialGroup()
																														.addGap(
																																238,
																																238,
																																238)
																														.addComponent(
																																op_orderedItems_label)
																														.addGap(
																																30,
																																30,
																																30))
																										.addGroup(
																												javax.swing.GroupLayout.Alignment.TRAILING,
																												layout
																														.createSequentialGroup()
																														.addPreferredGap(
																																javax.swing.LayoutStyle.ComponentPlacement.RELATED,
																																215,
																																Short.MAX_VALUE)
																														.addComponent(
																																op_modifyItems_button)
																														.addGap(
																																32,
																																32,
																																32)
																														.addComponent(
																																op_total_label)
																														.addPreferredGap(
																																javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																														.addComponent(
																																op_total_field)
																														.addGap(
																																110,
																																110,
																																110)))
																						.addGroup(
																								layout
																										.createSequentialGroup()
																										.addPreferredGap(
																												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																										.addComponent(
																												op_orderedItems_scrollpane,
																												javax.swing.GroupLayout.PREFERRED_SIZE,
																												503,
																												javax.swing.GroupLayout.PREFERRED_SIZE)
																										.addContainerGap()))
																		.addGroup(
																				javax.swing.GroupLayout.Alignment.TRAILING,
																				layout
																						.createSequentialGroup()
																						.addPreferredGap(
																								javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																						.addComponent(
																								op_processOrder_button2)
																						.addPreferredGap(
																								javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																						.addComponent(
																								op_deleteOrder_button2)
																						.addPreferredGap(
																								javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																						.addComponent(
																								op_createOrder_button2)
																						.addGap(
																								40,
																								40,
																								40)))
														.addGroup(
																javax.swing.GroupLayout.Alignment.TRAILING,
																layout
																		.createSequentialGroup()
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				op_print_button)
																		.addGap(
																				196,
																				196,
																				196))))
						.addGroup(
								layout.createSequentialGroup().addGap(90, 90,
										90).addComponent(op_createOrder_button)
										.addContainerGap(585, Short.MAX_VALUE)));

		layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
				new java.awt.Component[] { op_createOrder_button,
						op_deleteOrder_button, op_processOrder_button });

		layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
				new java.awt.Component[] { op_createOrder_button2,
						op_deleteOrder_button2, op_modifyItems_button,
						op_processOrder_button2 });

		layout
				.setVerticalGroup(layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								layout
										.createSequentialGroup()
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addGroup(
																layout
																		.createSequentialGroup()
																		.addContainerGap()
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addGroup(
																								layout
																										.createSequentialGroup()
																										.addGroup(
																												layout
																														.createParallelGroup(
																																javax.swing.GroupLayout.Alignment.BASELINE)
																														.addComponent(
																																op_orderID_field)
																														.addComponent(
																																op_selectOrder_button))
																										.addPreferredGap(
																												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																										.addGroup(
																												layout
																														.createParallelGroup(
																																javax.swing.GroupLayout.Alignment.BASELINE)
																														.addComponent(
																																op_driver_label)
																														.addComponent(
																																op_driver_field))
																										.addPreferredGap(
																												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																										.addGroup(
																												layout
																														.createParallelGroup(
																																javax.swing.GroupLayout.Alignment.BASELINE)
																														.addComponent(
																																op_routeOrder_field)
																														.addComponent(
																																op_routeOrder_label)))
																						.addComponent(
																								op_orderID_label))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				Short.MAX_VALUE)
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								op_orderStatus_label)
																						.addComponent(
																								op_orderStatus_field))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								op_soldToCustID_field)
																						.addComponent(
																								op_soldToCustID_label)
																						.addComponent(
																								op_selectCustomer_button))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								op_shipToName_field)
																						.addComponent(
																								op_shipToName_label))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								op_shipToAddress_field1)
																						.addComponent(
																								op_shipToAddress_label))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				op_shipToAddress_field2)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addGroup(
																								javax.swing.GroupLayout.Alignment.TRAILING,
																								layout
																										.createSequentialGroup()
																										.addGroup(
																												layout
																														.createParallelGroup(
																																javax.swing.GroupLayout.Alignment.BASELINE)
																														.addComponent(
																																op_shipToCity_field)
																														.addComponent(
																																op_shipToCity_label))
																										.addGap(
																												23,
																												23,
																												23))
																						.addGroup(
																								javax.swing.GroupLayout.Alignment.TRAILING,
																								layout
																										.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.BASELINE)
																										.addComponent(
																												op_shipToState_field)
																										.addComponent(
																												op_shipToState_label)))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addComponent(
																								jScrollPane2,
																								javax.swing.GroupLayout.PREFERRED_SIZE,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								javax.swing.GroupLayout.PREFERRED_SIZE)
																						.addComponent(
																								op_notes_label,
																								javax.swing.GroupLayout.PREFERRED_SIZE,
																								16,
																								javax.swing.GroupLayout.PREFERRED_SIZE))
																		.addGap(
																				9,
																				9,
																				9)
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addComponent(
																								op_directions_field,
																								javax.swing.GroupLayout.PREFERRED_SIZE,
																								62,
																								javax.swing.GroupLayout.PREFERRED_SIZE)
																						.addComponent(
																								op_directions_label))
																		.addGap(
																				3,
																				3,
																				3)
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								op_numPrinted_label)
																						.addComponent(
																								op_numPrinted_field))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								op_entryTime_label)
																						.addComponent(
																								op_entryTime_field))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								op_enteredBy_label)
																						.addComponent(
																								op_enteredBy_field))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								op_shipmentDate_label)
																						.addComponent(
																								op_shipmentDate_field))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								op_salespersonCode_label)
																						.addComponent(
																								op_salespersonCode_field))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								op_paymentTerms_label)
																						.addComponent(
																								op_paymentTerms_field))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								op_forman_label)
																						.addComponent(
																								op_foreman_field))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								op_billToCustID_label)
																						.addComponent(
																								op_billToCustID_field))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								op_priceSheet_label)
																						.addComponent(
																								op_priceSheet_combobox,
																								javax.swing.GroupLayout.PREFERRED_SIZE,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								javax.swing.GroupLayout.PREFERRED_SIZE))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								op_taxAreaCode_label)
																						.addComponent(
																								op_taxAreaCode_field)
																						.addComponent(
																								op_taxLiable_label)
																						.addComponent(
																								op_taxLiable_field))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED))
														.addGroup(
																layout
																		.createSequentialGroup()
																		.addGap(
																				20,
																				20,
																				20)
																		.addComponent(
																				op_orderedItems_label)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				op_orderedItems_scrollpane,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				396,
																				javax.swing.GroupLayout.PREFERRED_SIZE)
																		.addGap(
																				31,
																				31,
																				31)
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.TRAILING)
																						.addComponent(
																								op_modifyItems_button)
																						.addGroup(
																								layout
																										.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.BASELINE)
																										.addComponent(
																												op_total_label)
																										.addComponent(
																												op_total_field)))
																		.addGap(
																				78,
																				78,
																				78)
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.BASELINE)
																						.addComponent(
																								op_deleteOrder_button2)
																						.addComponent(
																								op_createOrder_button2)
																						.addComponent(
																								op_processOrder_button2))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED,
																				26,
																				Short.MAX_VALUE)
																		.addComponent(
																				op_print_button)
																		.addGap(
																				11,
																				11,
																				11)))
										.addGap(23, 23, 23)
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																op_processOrder_button)
														.addComponent(
																op_deleteOrder_button)
														.addComponent(
																op_createOrder_button))
										.addGap(45, 45, 45)));
	}// </editor-fold>
	//GEN-END:initComponents

	private void op_print_buttonActionPerformed(java.awt.event.ActionEvent evt) {
		if (this.op_orderStatus_field.getText().equals("Shipped")) {
			this.printOrder(evt);
		} else {
			if (this.op_orderID_field.getText().equals("-1")) {

				String errorText = "You must create the order before you can print it.";
				notificationDialog.displayNotification(errorText);
			} else if (this.op_orderID_field.getText().equals("000000")) {

				String errorText = "Please select an order to print.";
				notificationDialog.displayNotification(errorText);
			} else {
				this.print_dialog.setVisible(true);
				this.pd_info_label.setText(DEFAULT_MESSAGE);
			}
		}
	}

	private void pd_no_buttonActionPerformed(java.awt.event.ActionEvent evt) {
		this.print_dialog.setVisible(false);
	}

	private void pd_yes_buttonActionPerformed(java.awt.event.ActionEvent evt) {
		this.printOrder(evt);
	}

	private void modifyItems_PriceSheetSelect_comboboxActionPerformed(
			java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
		String curItemName = (String) modifyItems_ItemList_combobox
				.getSelectedItem();

		//get it from the list
		String psn = (String) this.modifyItems_PriceSheetSelect_combobox
				.getSelectedItem();
		System.out.println("Price sheet name we're trying to find the ID of: "
				+ psn);
		Items _itm;
		// Means the price sheet hasn't been selected yet
		if (psn == null) {
			// Using default values since price sheet isn't selected yet
			_itm = MEDIATOR.getItemFromList(curItemName);
		} else { // Uses the current selected price sheet's prices for the item instead
			int priceSheetID = MEDIATOR.getPSid(psn);
			System.out.println("Price sheet ID: " + priceSheetID);
			_itm = MEDIATOR.getItemFromList(curItemName, priceSheetID);
		}

		double price;
		//TODO this is really bad coupling
		if (modifyItems_UnitSelect_comobBox.getSelectedIndex() == 0) {
			price = _itm.getUnitPrice();
		} else {
			price = _itm.getOtherUnitPrice();
		}

		modifyItems_Price_label.setText(decimalPriceFormat.format(price));

		if (verify_modifyItems_Quantity_field()) {
			int q = 0;
			q = Integer.parseInt(modifyItems_Quantity_field.getText());
			modifyItems_total_label.setText(decimalPriceFormat
					.format((price * q)));
		}
	}

	private void modifyItems_ItemList_comboboxActionPerformed(
			java.awt.event.ActionEvent evt) {
		System.out.println("modifyItems_ItemList_comobBoxActionPerformed()");
		String curItemName = (String) modifyItems_ItemList_combobox
				.getSelectedItem();

		//get it from the list
		String psn = (String) this.modifyItems_PriceSheetSelect_combobox
				.getSelectedItem();
		System.out.println("Price sheet name we're trying to find the ID of: "
				+ psn);
		Items _itm;
		// Means the price sheet hasn't been selected yet
		if (psn == null) {
			// Using default values since price sheet isn't selected yet
			_itm = MEDIATOR.getItemFromList(curItemName);
		} else { // Uses the current selected price sheet's prices for the item instead
			int priceSheetID = MEDIATOR.getPSid(psn);
			System.out.println("Price sheet ID: " + priceSheetID);
			_itm = MEDIATOR.getItemFromList(curItemName, priceSheetID);
		}
		//TODO:check list

		//fill up the stuff
		this.modifyItems_ItemID_label.setText(Integer
				.toString(_itm.getItemID()));
		this.modifyItems_ItemDescription_label.setText(_itm
				.getItemDescription());
		this.modifyItems_UnitSelect_comobBox.removeAllItems();
		this.modifyItems_UnitSelect_comobBox.addItem(_itm.getUnitName());
		this.modifyItems_UnitSelect_comobBox.addItem(_itm.getOtherUnitName());
	}

	private void deleteOrder_dialog_cancel_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		deleteOrder_dialog.setEnabled(false);
		this.deleteOrder_dialog_cancel_button.setEnabled(false);
		this.deleteOrder_dialog_delete_button.setEnabled(false);
		deleteOrder_dialog.setVisible(false);
	}

	private void deleteOrder_dialog_delete_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {

		int OrderId = Integer.parseInt(this.op_orderID_field.getText());
		if (OrderId > 0) {

			MEDIATOR.deleteOrder(OrderId);

		}
		//clean up the screen
		this.clear_modifyItems_itemList_table();
		this.clear_op_orderedItems_table();

		//ask to select new order
		//this.selectCust_dialog_ORDER.setVisible(true);
		this.deleteOrder_dialog.setEnabled(false);
		this.deleteOrder_dialog_cancel_button.setEnabled(false);
		this.deleteOrder_dialog_delete_button.setEnabled(false);
		this.deleteOrder_dialog.setVisible(false);
		//bring up notification
		this.displayNotification("The order " + OrderId
				+ " was deleted. Please select a new order to proceed.");

	}

	private void selectDriver_dialog_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		//TODO: start of code we need to fix
		if (((String) selectDriver_dialog_combobox.getSelectedItem())
				.equals("Select a driver..."))
			selectDriver_dialog_error.setText("Please select a valid driver");
		else {
			String currentDriver = (String) selectDriver_dialog_combobox
					.getSelectedItem();

			// Set the new driver
			int orderID = Integer.parseInt(op_orderID_field.getText());
			MEDIATOR.setDriver(currentDriver, orderID);
			MEDIATOR.setOrderToShipped(orderID);

			// Sets the text for the driver label to the new driver
			op_driver_field.setText(currentDriver);

			// Fills out order screen with the new order information
			fill_Order_Information(op_orderID_field.getText());

			// Hides the dialog for driver selection now that we're done
			selectDriver_dialog.setVisible(false);

			//updates dates in CustomerHistory
			MEDIATOR.updateCustomerHistory(orderID);
		}
	}

	private void selectOrder_dialog_OK_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		String curOrder = (String) this.selectOrder_dialog_combobox
				.getSelectedItem();

		if (curOrder.equals("Select an order..."))
			selectOrder_dialog_error.setText("Please select a valid order");
		else {
			clear_op_orderedItems_table();
			clear_modifyItems_itemList_table();
			fill_Order_Information(curOrder);
			selectOrder_dialog.setVisible(false);

		}
	}

	private void modifyItems_Quantity_fieldCaretUpdate(
			javax.swing.event.CaretEvent evt) {
		System.out.print("sweeeet");
		if (verify_modifyItems_Quantity_field()) {
			//update total
			double price = Double
					.parseDouble(modifyItems_Price_label.getText());
			int q = Integer.parseInt(modifyItems_Quantity_field.getText());
			modifyItems_total_label.setText(decimalPriceFormat
					.format((price * q)));
		} else {
			//start yelling
			modifyItems_Quantity_field.setText("");
			this.modifyItems_total_label.setText("Total");

		}
	}

	private void modifyItems_UnitSelect_comobBoxActionPerformed(
			java.awt.event.ActionEvent evt) {
		System.out.println("modifyItems_UnitSelect_comobBoxActionPerformed()");
		String curItemName = (String) modifyItems_ItemList_combobox
				.getSelectedItem();

		//get it from the list
		String psn = (String) this.modifyItems_PriceSheetSelect_combobox
				.getSelectedItem();
		System.out.println("Price sheet name we're trying to find the ID of: "
				+ psn);
		Items _itm;
		// Means the price sheet hasn't been selected yet
		if (psn == null) {
			// Using default values since price sheet isn't selected yet
			_itm = MEDIATOR.getItemFromList(curItemName);
		} else { // Uses the current selected price sheet's prices for the item instead
			int priceSheetID = MEDIATOR.getPSid(psn);
			System.out.println("Price sheet ID: " + priceSheetID);
			_itm = MEDIATOR.getItemFromList(curItemName, priceSheetID);
		}

		double price;
		//TODO this is really bad coupling
		if (modifyItems_UnitSelect_comobBox.getSelectedIndex() == 0) {
			price = _itm.getUnitPrice();
		} else {
			price = _itm.getOtherUnitPrice();
		}

		modifyItems_Price_label.setText(decimalPriceFormat.format(price));

		if (verify_modifyItems_Quantity_field()) {
			int q = 0;
			q = Integer.parseInt(modifyItems_Quantity_field.getText());
			modifyItems_total_label.setText(decimalPriceFormat
					.format((price * q)));
		}
	}

	private void modifyItems_addSelectedItem_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		//find next empty line
		int i = find_next_empty_line_in_op_orderedItems_table();
		int opRowSize = this.getRowSizeOfOP();
		int miRowSize = this.getRowSizeOfMI();

		System.out.println("miRowSize: " + miRowSize);
		System.out.println("opRowSize: " + opRowSize);
		// Means that we want to add more items than there are lines
		// So we increase the size to accommodate all the items
		if (miRowSize > opRowSize) {
			System.out.println("Adding Rows");
			this.addRowsToOP(miRowSize - opRowSize);
			System.out.println("finished adding " + (miRowSize - opRowSize)
					+ " rows");
		}
		boolean error_flag = false;
		//		if (i == -1) {
		//			error_flag = true;
		//			this.modifyLabel_errorMessageLabel
		//					.setText("ERROR: CANT FIND EMPTY LINE in op_orderedItems_table");
		//		}
		//
		//		else {
		if (validate_Quantity_Column_in_modifyItems_itemList_table()) {
			System.out.println("found NOT empty order");
			int row = 0;

			boolean flag = true;
			boolean not_zero_flag = true;
			while ((Integer) this.modifyItems_itemList_table.getValueAt(row,
					MI_ID_COLUMN) != 0
					&& flag) {

				int itemID = (Integer) modifyItems_itemList_table.getValueAt(
						row, MI_ID_COLUMN);
				int curItemID = (Integer) op_orderedItems_table.getValueAt(row,
						OP_ID_COLUMN);
				//String UnitName = (String) modifyItems_itemList_table
				//		.getValueAt(row, MI_UNIT_COLUMN);

				//some consistency checks
				if (curItemID == 0) {//since eventually we will reach new items the curItemID will be 0 which 
					//won't equal to itemID, but is valid. Thus we avoid it here
					not_zero_flag = false;
				}

				if (not_zero_flag) {
					if (curItemID != itemID) {//aka two lists are out of order\sync
						System.out
								.println("Modify_Item onAction(ConfirmChanges) curItemID != itemID");
						flag = false;
						error_flag = true;

					}
				}

				this.op_orderedItems_table.setValueAt(
						this.modifyItems_itemList_table.getValueAt(row,
								MI_ID_COLUMN), row, OP_ID_COLUMN);//itemid
				this.op_orderedItems_table.setValueAt(
						this.modifyItems_itemList_table.getValueAt(row,
								MI_NAME_COLUMN), row, OP_NAME_COLUMN);//itemname
				this.op_orderedItems_table.setValueAt(
						this.modifyItems_itemList_table.getValueAt(row,
								MI_DESCRIPTION_COLUMN), row,
						OP_DESCRIPTION_COLUMN);//descrip
				this.op_orderedItems_table.setValueAt(
						this.modifyItems_itemList_table.getValueAt(row,
								MI_UNIT_COLUMN), row, OP_UNIT_COLUMN);//unit

				// q = quantity
				int q = (Integer) this.modifyItems_itemList_table.getValueAt(
						row, MI_QUANTITY_COLUMN);
				this.op_orderedItems_table.setValueAt(q, row,
						OP_QUANTITY_COLUMN);
				//q

				//p = price
				Float p = (Float) this.modifyItems_itemList_table.getValueAt(
						row, MI_UNITPRICE_COLUMN);
				this.op_orderedItems_table.setValueAt(p, row, OP_PRICE_COLUMN);
				//p

				// subtotal
				this.op_orderedItems_table.setValueAt((p * q), row,
						OP_SUBTOTAL_COLUMN);

				row++;
			}

			this.updateTotalPrice();
			this.modifyItems_dialog.setVisible(error_flag);

		}
		//		}
	}

	private void modifyItems_addNewItem_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		if (verify_modifyItems_Quantity_field()) {
			//find next empty line
			int i = find_next_empty_line_index_in_modifyItems_itemList();

			int itemID = Integer.parseInt(modifyItems_ItemID_label.getText());
			String unit = (String) modifyItems_UnitSelect_comobBox
					.getSelectedItem();

			if (unit.equals(get_Unit_from_ModifyItem_table(itemID))) {
				this.modifyLabel_errorMessageLabel
						.setText("ERROR: Cant add two items with the same units");

			} else {
				if (i == -1) {
					this.modifyLabel_errorMessageLabel
							.setText("ERROR: CANT FIND EMPTY LINE in modifyItems_itemList");
				} else {
					//fill it in with info

					//itemID
					this.modifyItems_itemList_table.setValueAt(itemID, i,
							MI_ID_COLUMN);

					//item Name
					this.modifyItems_itemList_table.setValueAt(
							(String) this.modifyItems_ItemList_combobox
									.getSelectedItem(), i, MI_NAME_COLUMN);

					//item Description
					this.modifyItems_itemList_table.setValueAt(
							modifyItems_ItemDescription_label.getText(), i,
							MI_DESCRIPTION_COLUMN);

					//Quantity
					this.modifyItems_itemList_table.setValueAt(Integer
							.parseInt(modifyItems_Quantity_field.getText()), i,
							MI_QUANTITY_COLUMN);

					//UnitName
					this.modifyItems_itemList_table.setValueAt(unit, i,
							MI_UNIT_COLUMN);

					//UnitPrice
					this.modifyItems_itemList_table.setValueAt(Float
							.parseFloat(modifyItems_Price_label.getText()), i,
							MI_UNITPRICE_COLUMN);

					//Total
					this.modifyItems_itemList_table.setValueAt(Float
							.parseFloat(modifyItems_total_label.getText()), i,
							MI_AMOUNT_COLUMN);
				}
			}

		} else {
			this.modifyLabel_errorMessageLabel
					.setText("Can't add items due to incorrect input");
		}
	}

	private void modifyItems_itemList_tableFocusLost(
			java.awt.event.FocusEvent evt) {
		// TODO add your handling code here:
	}

	private void selectCust_dialog_ORDER_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		int CustID = MEDIATOR
				.getCustomerID((String) selectCust_dialog_ORDER_combobox
						.getSelectedItem());
		if (CustID == -1) {
			selectCust_dialog_ORDER_error
					.setText("Please select a valid customer");
		} else {
			op_soldToCustID_field.setText(Integer.toString(CustID));
			selectCust_dialog_ORDER.setVisible(false);
			fill_Order_Screen();
			if (op_orderID_field.getText().equals("-1")) {
				modifyItems_itemID_combobox_populate();
				this.fillPriceSheetComboboxInMI();
				this.fill_Order_Table_in_ModifyItems_dialog();
				this.activate_Modify_Items_Dialog();
			} else {
				selectOrder_dialog.setVisible(true);
				updateSelectOrderCombobox();
			}
		}
	}

	private void selectCust_dialog_ORDER_comboboxActionPerformed(
			java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	//NAME: create/save order button
	//IN:   none
	//OUT:  none
	//FUNC: takes the information from the order panel table and saves
	//it as a new order or modifies an existing order
	private void op_createOrder_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		//first of all try grabbing the notes
		String notes;
		try {
			notes = (String) this.op_notes_field.getText();
			//and trim to LENGTH
			if(notes.length() > NOTE_LENGTH)
			{
				notes = notes.substring(0, NOTE_LENGTH - 1);
			}
		} catch (NullPointerException e) {
			e.printStackTrace();
			notes = "";
		}

		//check if the order is new
		if (this.op_orderID_field.getText() == "-1") {
			//create new order
			ArrayList<Ordereditems> _ordItms = new ArrayList<Ordereditems>();
			boolean flag = true;
			int i = 0;
			while ((Integer) this.op_orderedItems_table.getValueAt(i,
					OP_ID_COLUMN) != 0) {

				System.out.println(i);
				int q = (Integer) this.op_orderedItems_table.getValueAt(i,
						OP_QUANTITY_COLUMN);

				if (q != 0)//do not add items with quantity == 0 to order
				{
					Ordereditems _oi = new Ordereditems();
					_oi.setItemID((Integer) this.op_orderedItems_table
							.getValueAt(i, OP_ID_COLUMN));//itemID
					_oi.setItemUnit((String) this.op_orderedItems_table
							.getValueAt(i, OP_UNIT_COLUMN));//unit
					_oi.setQuantityOrdered(q);//q

					Float p = (Float) this.op_orderedItems_table.getValueAt(i,
							OP_PRICE_COLUMN);
					_oi.setPriceAtPurchase(p.floatValue());

					_ordItms.add(_oi);
				}
				i++;
			}

			if (!_ordItms.isEmpty()) {
				MEDIATOR.createNewOrder(Integer
						.parseInt(this.op_soldToCustID_field.getText()),
						_ordItms, notes);
				notificationDialog
						.displayNotification("Order was successfully created!");
			} else {
				notificationDialog
						.displayNotification("Please add items before creating the order.");
			}
		}
		//this is an old order that requires modification
		else {
			//modify old order
			int OrderID = Integer.parseInt(op_orderID_field.getText());
			ArrayList<Ordereditems> _curItems = MEDIATOR
					.getOrderedItemsARL(OrderID);
			ArrayList<Ordereditems> _newItems = new ArrayList<Ordereditems>();
			boolean flag = true;
			boolean found_in_order_flag = false;

			int i = 0;

			while (flag) {
				int itemID = (Integer) this.op_orderedItems_table.getValueAt(i,
						OP_ID_COLUMN);
				String unitName = (String) this.op_orderedItems_table
						.getValueAt(i, OP_UNIT_COLUMN);

				//this section searches the existing order to find this item
				//and if it is there adds it to the new order list with necessary modifications.
				for (int j = 0; j < _curItems.size(); j++)//might throw an out of bounds bug
				{
					if (_curItems.get(j).getItemID() == itemID) {
						System.out
								.println("Found an item where _ordItms.get(i).getItemID() == itemID = "
										+ itemID);
						if (_curItems.get(j).getItemUnit().equals(unitName)) {
							System.out
									.println("Found an item where _ordItms2.get(j).getItemUnit().equals(unitName) "
											+ unitName);
							Ordereditems _oitm = _curItems.get(j);
							_curItems.remove(j);

							Float p = (Float) this.op_orderedItems_table
									.getValueAt(i, OP_PRICE_COLUMN);
							_oitm.setPriceAtPurchase(p.floatValue());
							_oitm
									.setQuantityOrdered((Integer) this.op_orderedItems_table
											.getValueAt(i, OP_QUANTITY_COLUMN));
							_newItems.add(_oitm);
							found_in_order_flag = true;
							j = _curItems.size() + 10;
						}

					}
				}

				if (!found_in_order_flag)//then this item was not in order and has to be added
				{
					Ordereditems _oitm = new Ordereditems();

					_oitm.setItemID(itemID);
					_oitm.setItemUnit(unitName);
					_oitm.setOrderID(OrderID);

					Float p = (Float) this.op_orderedItems_table.getValueAt(i,
							OP_PRICE_COLUMN);
					_oitm.setPriceAtPurchase(p.floatValue());
					_oitm
							.setQuantityOrdered((Integer) this.op_orderedItems_table
									.getValueAt(i, OP_QUANTITY_COLUMN));

					//					_oitm.setOrderedItemID(-1); //TODO: fix it
					_newItems.add(_oitm);
				}
				i++;
				if ((Integer) this.op_orderedItems_table.getValueAt(i,
						OP_ID_COLUMN) == 0) {
					flag = false;
				}
				found_in_order_flag = false;

			}

			MEDIATOR.modifyOrder(Integer.parseInt(this.op_soldToCustID_field
					.getText()), _newItems, notes);
			notificationDialog
					.displayNotification("Order was successfully modified!");
		}
		//clean up the screen
		this.clear_modifyItems_itemList_table();
		this.clear_op_orderedItems_table();
		//ask to select new order
		//		this.selectOrder_dialog.setVisible(true);//TODO:BS
	}

	//NAME: op_modifyItems_buttonActionPerformed
	//IN: none
	//OUT: none
	//FUNC: opens the modify items dialog window if the customer is selected
	//does some other house-keeping duties for modify-items window like:
	//populates ItemID combobox, populates priceSheet combobox.
	private void op_modifyItems_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		//if one didn't select a customer one can't really see the items this
		//person ordered. Thus we bring forward the select customer dialog
		if (this.op_soldToCustID_field.getText().equals("")) {
			selectCust_dialog_ORDER.setVisible(true);
			updateSelectCustomerComboboxInORDER();
		}

		//otherwise we populate items combo-box and set the necessary dialog visible.
		else {
			this.modifyItems_itemID_combobox_populate();
			this.fillPriceSheetComboboxInMI();
			this.activate_Modify_Items_Dialog();
			//clean out the stuff on modifyItems
			this.clear_modifyItems_itemList_table();
			this.copyOPTableToMITable();

			this.fill_Order_Table_in_ModifyItems_dialog();

		}
	}

	// Copies all values from op_orderedItems_table to modifyItems_itemList_table
	private void copyOPTableToMITable() {
		int rows = op_orderedItems_table.getModel().getRowCount();
		int curRow = 0;

		// Keep copying until 1) current ID = 0 (default val)
		//                    2) there are no more rows available to copy
		while ((Integer) op_orderedItems_table.getValueAt(curRow, OP_ID_COLUMN) != 0
				&& curRow < rows) {

			// ID
			modifyItems_itemList_table.setValueAt(op_orderedItems_table
					.getValueAt(curRow, OP_ID_COLUMN), curRow, MI_ID_COLUMN);

			// Name
			modifyItems_itemList_table
					.setValueAt(op_orderedItems_table.getValueAt(curRow,
							OP_NAME_COLUMN), curRow, MI_NAME_COLUMN);

			// Description
			modifyItems_itemList_table.setValueAt(op_orderedItems_table
					.getValueAt(curRow, OP_DESCRIPTION_COLUMN), curRow,
					MI_DESCRIPTION_COLUMN);

			// Unit
			modifyItems_itemList_table
					.setValueAt(op_orderedItems_table.getValueAt(curRow,
							OP_UNIT_COLUMN), curRow, MI_UNIT_COLUMN);

			// Quantity
			modifyItems_itemList_table.setValueAt(op_orderedItems_table
					.getValueAt(curRow, OP_QUANTITY_COLUMN), curRow,
					MI_QUANTITY_COLUMN);

			// Price
			modifyItems_itemList_table.setValueAt(op_orderedItems_table
					.getValueAt(curRow, OP_PRICE_COLUMN), curRow,
					MI_UNITPRICE_COLUMN);

			// Subtotal
			modifyItems_itemList_table.setValueAt(op_orderedItems_table
					.getValueAt(curRow, OP_SUBTOTAL_COLUMN), curRow,
					MI_AMOUNT_COLUMN);

			// Increment so we go to the next row
			curRow++;
		}
	}

	private void activate_Modify_Items_Dialog() {
		if (this.isItemListEmpty()) {
			//			// this.notificationDialog.setVisible(true);  bug # 102

			String error = "<html><p style=\"text-align: center; color: red;\">";
			error += "WARNING: No active items<p><p>";
			error += "Fix this by activating an item in the items screen</p></html>";

			notificationDialog.displayNotification(error);

			//			this.displayNotification("WARNING: No active items. Fix this by activating an item in the items screen");

		} else {
			modifyItems_dialog.setVisible(true);
		}
	}

	private boolean isItemListEmpty() {
		return MEDIATOR.getActiveItemsListLength() == 0;
	}

	private void op_selectOrder_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		if (this.op_soldToCustID_field.getText().equals("0000000")) {
			selectCust_dialog_ORDER.setVisible(true);
			updateSelectCustomerComboboxInORDER();
		} else {
			this.selectOrder_dialog.setVisible(true);
			updateSelectOrderCombobox();
		}
	}

	private void op_selectCustomer_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		this.op_orderID_field.setText("000000");
		//		this.setOrderPanelOnTop();
		selectCust_dialog_ORDER.setVisible(true);
		updateSelectCustomerComboboxInORDER();
	}

	private void op_deleteOrder_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {

		//can't delete an order that doesn't exist
		if (this.op_orderID_field.getText().equals("000000")
				|| this.op_orderID_field.getText().equals("-1")) {
			//TODO: notify that can't do this
			notificationDialog
					.displayNotification("<html>Error!<p>Can't delete an order when one is not selected.<p>Please select an order to delete.</html>");
		} else if (this.op_orderID_field.getText().equals("-1")) {
			notificationDialog
					.displayNotification("<html>Error!<p>Can't delete an unsaved order since there's nothing to delete.");
		} else {
			this.deleteOrder_dialog.setEnabled(true);
			this.deleteOrder_dialog_cancel_button.setEnabled(true);
			this.deleteOrder_dialog_delete_button.setEnabled(true);
			this.deleteOrder_dialog.setVisible(true);
		}

	}

	private void op_processOrder_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		////////////////////////
		//check if data exists//
		////////////////////////

		if (this.op_orderID_field.getText() != "-1") {
			Integer id_value = (Integer) this.op_orderedItems_table.getValueAt(
					0, this.OP_ID_COLUMN); //bug # 120
			if (id_value == 0) {
				////////
				// no //
				////////
				this
						.displayNotification("<html>You can't process an order with no items.<p>Please add some items first.</html>");

			} else {
				/////////
				// yes //
				/////////
				//Integer 

				selectDriver_dialog.setVisible(true);
				updateDriverCombobox();

			}
		} else { //trying to process an order that hasn't been saved
			notificationDialog
					.displayNotification("<html>Cannot process an unsaved order.<p><p>Please Save the order before processing.");
		}
	}

	//GEN-BEGIN:variables
	// Variables declaration - do not modify
	private javax.swing.JDialog deleteOrder_dialog;
	private javax.swing.JButton deleteOrder_dialog_cancel_button;
	private javax.swing.JButton deleteOrder_dialog_delete_button;
	private javax.swing.JLabel deleteOrder_dialog_label;
	private javax.swing.JScrollPane jScrollPane2;
	private javax.swing.JScrollPane jScrollPane6;
	private javax.swing.JLabel mo_ItemName_Label;
	private javax.swing.JLabel mo_Total_label;
	private javax.swing.JLabel mo_description_label;
	private javax.swing.JLabel mo_itemID_label;
	private javax.swing.JLabel mo_price_label;
	private javax.swing.JLabel mo_pricesheet_label;
	private javax.swing.JLabel mo_quantity_label;
	private javax.swing.JLabel mo_unit_label;
	private javax.swing.JLabel modifyItems_ItemDescription_label;
	private javax.swing.JLabel modifyItems_ItemID_label;
	private javax.swing.JComboBox modifyItems_ItemList_combobox;
	private javax.swing.JComboBox modifyItems_PriceSheetSelect_combobox;
	private javax.swing.JLabel modifyItems_Price_label;
	private javax.swing.JTextField modifyItems_Quantity_field;
	private javax.swing.JComboBox modifyItems_UnitSelect_comobBox;
	private javax.swing.JButton modifyItems_addNewItem_button;
	private javax.swing.JButton modifyItems_addSelectedItem_button;
	private javax.swing.JDialog modifyItems_dialog;
	private javax.swing.JLabel modifyItems_itemList_label;
	private javax.swing.JTable modifyItems_itemList_table;
	private javax.swing.JLabel modifyItems_total_label;
	private javax.swing.JLabel modifyLabel_errorMessageLabel;
	private javax.swing.JLabel op_billToCustID_field;
	private javax.swing.JLabel op_billToCustID_label;
	private javax.swing.JButton op_createOrder_button;
	private javax.swing.JButton op_createOrder_button2;
	private javax.swing.JButton op_deleteOrder_button;
	private javax.swing.JButton op_deleteOrder_button2;
	private javax.swing.JLabel op_directions_field;
	private javax.swing.JLabel op_directions_label;
	private javax.swing.JLabel op_driver_field;
	private javax.swing.JLabel op_driver_label;
	private javax.swing.JLabel op_enteredBy_field;
	private javax.swing.JLabel op_enteredBy_label;
	private javax.swing.JLabel op_entryTime_field;
	private javax.swing.JLabel op_entryTime_label;
	private javax.swing.JLabel op_foreman_field;
	private javax.swing.JLabel op_forman_label;
	private javax.swing.JButton op_modifyItems_button;
	private javax.swing.JTextArea op_notes_field;
	private javax.swing.JLabel op_notes_label;
	private javax.swing.JLabel op_numPrinted_field;
	private javax.swing.JLabel op_numPrinted_label;
	private javax.swing.JLabel op_orderID_field;
	private javax.swing.JLabel op_orderID_label;
	private javax.swing.JLabel op_orderStatus_field;
	private javax.swing.JLabel op_orderStatus_label;
	private javax.swing.JLabel op_orderedItems_label;
	private javax.swing.JScrollPane op_orderedItems_scrollpane;
	private javax.swing.JTable op_orderedItems_table;
	private javax.swing.JLabel op_paymentTerms_field;
	private javax.swing.JLabel op_paymentTerms_label;
	private javax.swing.JComboBox op_priceSheet_combobox;
	private javax.swing.JLabel op_priceSheet_label;
	private javax.swing.JButton op_print_button;
	private javax.swing.JButton op_processOrder_button;
	private javax.swing.JButton op_processOrder_button2;
	private javax.swing.JLabel op_routeOrder_field;
	private javax.swing.JLabel op_routeOrder_label;
	private javax.swing.JLabel op_salespersonCode_field;
	private javax.swing.JLabel op_salespersonCode_label;
	private javax.swing.JButton op_selectCustomer_button;
	private javax.swing.JButton op_selectOrder_button;
	private javax.swing.JLabel op_shipToAddress_field1;
	private javax.swing.JLabel op_shipToAddress_field2;
	private javax.swing.JLabel op_shipToAddress_label;
	private javax.swing.JLabel op_shipToCity_field;
	private javax.swing.JLabel op_shipToCity_label;
	private javax.swing.JLabel op_shipToName_field;
	private javax.swing.JLabel op_shipToName_label;
	private javax.swing.JLabel op_shipToState_field;
	private javax.swing.JLabel op_shipToState_label;
	private javax.swing.JLabel op_shipmentDate_field;
	private javax.swing.JLabel op_shipmentDate_label;
	private javax.swing.JLabel op_soldToCustID_field;
	private javax.swing.JLabel op_soldToCustID_label;
	private javax.swing.JLabel op_taxAreaCode_field;
	private javax.swing.JLabel op_taxAreaCode_label;
	private javax.swing.JLabel op_taxLiable_field;
	private javax.swing.JLabel op_taxLiable_label;
	private javax.swing.JLabel op_total_field;
	private javax.swing.JLabel op_total_label;
	private javax.swing.JLabel pd_info_label;
	private javax.swing.JButton pd_no_button;
	private javax.swing.JButton pd_yes_button;
	private javax.swing.JScrollPane ppd_preview_scrollpane;
	private javax.swing.JTextArea ppd_preview_textarea;
	private javax.swing.JDialog printPreview_dialog;
	private javax.swing.JDialog print_dialog;
	private javax.swing.JDialog selectCust_dialog_ORDER;
	private javax.swing.JButton selectCust_dialog_ORDER_button;
	private javax.swing.JComboBox selectCust_dialog_ORDER_combobox;
	private javax.swing.JLabel selectCust_dialog_ORDER_error;
	private javax.swing.JLabel selectCust_dialog_ORDER_label;
	private javax.swing.JDialog selectDriver_dialog;
	private javax.swing.JButton selectDriver_dialog_button;
	private javax.swing.JComboBox selectDriver_dialog_combobox;
	private javax.swing.JLabel selectDriver_dialog_error;
	private javax.swing.JLabel selectDriver_dialog_label;
	private javax.swing.JDialog selectOrder_dialog;
	private javax.swing.JButton selectOrder_dialog_OK_button;
	private javax.swing.JComboBox selectOrder_dialog_combobox;
	private javax.swing.JLabel selectOrder_dialog_error;
	private javax.swing.JLabel selectOrder_dialog_label;
	// End of variables declaration//GEN-END:variables
	private com.popsGUI.java.notificationDialog notificationDialog;
	//TODO: the start of our code
	////////////////Our variable declarations /////////////////
	//	CustomersDao CustomersDAO = CustomersDaoFactory.create();
	//	ItemsDao ItemsDAO = ItemsDaoFactory.create();
	//	OrdereditemsDao OrdereditemsDAO = OrdereditemsDaoFactory.create();
	//	OrdersDao OrdersDAO = OrdersDaoFactory.create();

	Mediator MEDIATOR = Mediator.getInstance();

	DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm");
	DecimalFormat decimalPriceFormat = new DecimalFormat("#########0.00");

	//Default number of rows in the table to begin with
	final int DEFAULT_ROW_SIZE = 30;
	final int DEFAULT_ADD_SIZE = 10;

	// Initialized directly after initComponents(), so we have the true defaults
	private TableModel DEFAULT_OP_TABLE;
	private TableModel DEFAULT_MI_TABLE;

	final int NOTE_LENGTH = 160;

	// column indexes for op_orderedItems_table
	final int OP_ID_COLUMN = 0;
	final int OP_NAME_COLUMN = 1;
	final int OP_DESCRIPTION_COLUMN = 2;
	final int OP_UNIT_COLUMN = 3;
	final int OP_QUANTITY_COLUMN = 4;
	final int OP_PRICE_COLUMN = 5;
	final int OP_SUBTOTAL_COLUMN = 6;

	// column indexes for modifyItems_itemList_table
	final int MI_ID_COLUMN = 0;
	final int MI_NAME_COLUMN = 1;
	final int MI_DESCRIPTION_COLUMN = 2;
	final int MI_QUANTITY_COLUMN = 3;
	final int MI_UNIT_COLUMN = 4;
	final int MI_UNITPRICE_COLUMN = 5;
	final int MI_AMOUNT_COLUMN = 6;

	private javax.swing.JTextArea printPreview = new javax.swing.JTextArea();

	final String DEFAULT_MESSAGE = "<html>Orders must be saved before printing.<p><p>Do you want to save this order?";

	final String ITEM_HEADER = "\nID \tName \t\t\t\tUnit \tQuantity \tItem Price \tSubtotal\n";
	final int MAX_TABS = 4;
	final int TAB_LENGTH = 13;

	///////////// End of our variable declarations /////////////

	private void getTableDefaults() {
		DEFAULT_OP_TABLE = op_orderedItems_table.getModel();
		DEFAULT_MI_TABLE = modifyItems_itemList_table.getModel();
	}

	// Disables or enables all interactive components in the order panel
	public void setOrderPanelComponentsEnabledParameterTo(boolean flag) {
		this.setEnabled(flag);
		this.op_selectOrder_button.setEnabled(flag);
		this.op_selectCustomer_button.setEnabled(flag);
		this.op_priceSheet_combobox.setEnabled(flag);
		this.op_processOrder_button2.setEnabled(flag);
		this.op_deleteOrder_button2.setEnabled(flag);
		this.op_createOrder_button2.setEnabled(flag);
		this.op_modifyItems_button.setEnabled(flag);

		this.deleteOrder_dialog.setEnabled(flag);
		this.deleteOrder_dialog_cancel_button.setEnabled(false);
		this.deleteOrder_dialog_delete_button.setEnabled(false);

		this.op_createOrder_button.setVisible(false);
		this.op_createOrder_button.setEnabled(false);
		this.op_deleteOrder_button.setVisible(false);
		this.op_deleteOrder_button.setEnabled(false);
		this.op_processOrder_button.setVisible(false);
		this.op_processOrder_button.setEnabled(false);
	}

	// Fills out order specific fields in the order screen when an order is selected
	private void fill_Order_Information(String id) {
		// Converts the string into a usable int
		int orderID = Integer.parseInt(id);
		fill_Order_Table_in_op(orderID);

		// Gets the order associated with the specified ID
		Orders order = MEDIATOR.getOrderWithID(orderID);

		// Fills out relevant fields in the order screen
		op_orderID_field.setText(id);
		//		op_routeOrder_field.setText();

		op_orderStatus_field.setText(getStatusText(order.getStatus()));
		op_notes_field.setText(order.getNotes());
		op_entryTime_field.setText(dateFormat.format(order.getEnteredTime()));
		op_enteredBy_field.setText(MEDIATOR.getEmployeeName(order
				.getEnteredByID()));
		if (order.getShipmentDate() == null) {
			op_shipmentDate_field.setText("not shipped yet");
		} else {
			op_shipmentDate_field.setText(dateFormat.format(order
					.getShipmentDate()));
		}

		op_billToCustID_field.setText(Integer.toString(order.getBillingID()));
	}

	private void fill_Order_Table_in_op(int OrderID) {
		Ordereditems[] _ordredItems = MEDIATOR.getOrderedItems(OrderID);
		for (int i = 0; i < _ordredItems.length; i++) {
			//set up Order_Table_in_op

			Items _itm = MEDIATOR.getItem(_ordredItems[i].getItemID());

			//set itemID
			this.op_orderedItems_table.setValueAt(_itm.getItemID(), i,
					OP_ID_COLUMN);
			//set itemName
			this.op_orderedItems_table.setValueAt(_itm.getItemName(), i,
					OP_NAME_COLUMN);
			//set itemDescription
			this.op_orderedItems_table.setValueAt(_itm.getItemDescription(), i,
					OP_DESCRIPTION_COLUMN);
			//set unit
			this.op_orderedItems_table.setValueAt(
					_ordredItems[i].getItemUnit(), i, OP_UNIT_COLUMN);
			//set quantity
			int q = _ordredItems[i].getQuantityOrdered();
			float p = _ordredItems[i].getPriceAtPurchase();
			this.op_orderedItems_table.setValueAt(q, i, OP_QUANTITY_COLUMN);
			//set itemprice
			this.op_orderedItems_table.setValueAt(p, i, OP_PRICE_COLUMN);
			//set subtotal
			this.op_orderedItems_table.setValueAt((q * p), i,
					OP_SUBTOTAL_COLUMN);
		}

		this.updateTotalPrice();
	}

	private void updateTotalPrice() {
		int totalRows = this.op_orderedItems_table.getModel().getRowCount();
		double price = 0;
		for (int i = 0; i < totalRows; i++) {
			if (op_orderedItems_table.getValueAt(i, OP_SUBTOTAL_COLUMN) != null) {
				Float curVal = (Float) this.op_orderedItems_table.getValueAt(i,
						this.OP_SUBTOTAL_COLUMN);
				System.out.println(curVal);
				price += curVal;
			}
		}

		this.op_total_field.setText(this.decimalPriceFormat.format(price));
	}

	//NAME: fill_Order_Table_in_ModifyItems_dialog
	//IN:   none
	//OUT:  none
	//FUNC: fills the order table with the order information and order history
	public void fill_Order_Table_in_ModifyItems_dialog() {
		System.out.println("fill_Order_Table_in_ModifyItems_dialog");
		///////////////////////////////////////
		// Grab the current price sheet data //
		///////////////////////////////////////
		//TODO: get the current price sheet id
		//		MEDIATOR.getCompleteListOfPrices(PSid);

		////////////////////////////////////  
		// fill out the order information //
		////////////////////////////////////

		int OrderID = Integer.parseInt(this.op_orderID_field.getText());

		Ordereditems[] _ordredItems = MEDIATOR.getOrderedItems(OrderID);
		int row = 0;
		for (row = 0; row < _ordredItems.length; row++) {
			//set up Order_Table_in_op

			Items _itm = MEDIATOR.getItem(_ordredItems[row].getItemID());

			//set up ModifyItems table

			add_item_to_Order_Table_in_Modify_Items_Dialog(row, _itm,
					_ordredItems[row].getPriceAtPurchase(), _ordredItems[row]
							.getQuantityOrdered(), _ordredItems[row]
							.getItemUnit());
			//pricegroup TODO
			//	this.modifyItems_itemList_table.setValueAt(aValue, i, MI_PRICEGROUP_COLUMN);	

		}

		///////////////////////////////////
		// fill out price sheet combobox //
		///////////////////////////////////
		this.fillPriceSheetComboboxInMI();

		///////////////////////////////////////////
		// fill out the order history information//
		///////////////////////////////////////////

		ArrayList<Items> itms_hist = MEDIATOR.getCustomerHistory(Integer
				.parseInt(this.op_soldToCustID_field.getText()));

		for (int i = 0; i < itms_hist.size(); i++) {
			// make sure the item is active

			if (itms_hist.get(i).getIsActive() == 1) {
				// TODO: this selection can be done by using a more intelligent MySQL query
				// SELECT Orders od
				// WHERE CustomerID = Customerorderhistory.CustomerID 
				//         AND Customerorderhistory.ItemID != OrderedItems.ItemID WHERE OrderedItems.OrderID = OrderID
				//check if order already exists
				boolean found_flag = false;

				for (int x = 0; x < _ordredItems.length; x++) {
					if (_ordredItems[x].getItemID() == itms_hist.get(i)
							.getItemID()) {
						found_flag = true;
					}

				}

				if (!found_flag) {
					// Gets the current customer ID
					// Gets the price sheet ID of the current customer
					int custID = Integer.parseInt(this.op_soldToCustID_field
							.getText());
					int psID = MEDIATOR.getCustomerPriceSheetID(custID);

					// Gets the item with the prices based on the customer's default price sheet
					Items _item = MEDIATOR.getItemFromList(itms_hist.get(i)
							.getItemName(), psID);

					add_item_to_Order_Table_in_Modify_Items_Dialog(row, _item,
							_item.getUnitPrice(), 0, _item.getUnitName());
					row++;
				}
			}
		}
	}

	//NAME:  add_item_to_Order_Table_in_Modify_Items_Dialog
	//IN:    the row into which to insert the information; the item to insert;
	//       price of the item, unit of the item, quantity of the item
	//OUT:   none
	//FUNC:  inserts the information about the given item into the given row
	private void add_item_to_Order_Table_in_Modify_Items_Dialog(int row,
			Items _itm, float p, int q, String unit) {
		//id
		this.modifyItems_itemList_table.setValueAt(_itm.getItemID(), row,
				MI_ID_COLUMN);
		//name
		this.modifyItems_itemList_table.setValueAt(_itm.getItemName(), row,
				MI_NAME_COLUMN);
		//description
		this.modifyItems_itemList_table.setValueAt(_itm.getItemDescription(),
				row, MI_DESCRIPTION_COLUMN);
		//quantity
		this.modifyItems_itemList_table.setValueAt(q, row, MI_QUANTITY_COLUMN);
		//unitprice
		this.modifyItems_itemList_table.setValueAt(p, row, MI_UNITPRICE_COLUMN);

		//unit
		this.modifyItems_itemList_table.setValueAt(unit, row, MI_UNIT_COLUMN);

		//total amount
		this.modifyItems_itemList_table.setValueAt((q * p), row,
				MI_AMOUNT_COLUMN);
	}

	//NAME:  getStatusText
	//IN:    status variable in a form of short
	//OUT:   string describing status
	//FUNC:  Returns the string to place into the op_custStatus_field
	// 	     Also enables or disables buttons based on customer status,
	//       because the user should not be able to make any changes to shipped orders
	private String getStatusText(short status) {
		if (status == 1) {
			op_createOrder_button2.setEnabled(false);
			op_processOrder_button2.setEnabled(false);
			op_deleteOrder_button2.setEnabled(false);
			op_modifyItems_button.setEnabled(false);
			return "Shipped";
		} else {
			op_createOrder_button2.setEnabled(true);
			op_processOrder_button2.setEnabled(true);
			op_deleteOrder_button2.setEnabled(true);
			op_modifyItems_button.setEnabled(true);
			return "Pending...";
		}
	}

	private void clear_op_orderedItems_table() {
		//TODO: get this to work
		//		if (op_orderedItems_table.getModel().getRowCount() != DEFAULT_ROW_SIZE) {
		//			op_orderedItems_table.setModel(DEFAULT_OP_TABLE);
		//		} else {
		boolean flag = true;
		int row = 0;
		while (flag) {
			// op_orderedItems_table.setValueAt(aValue, row, column)
			op_orderedItems_table.setValueAt(0, row, OP_ID_COLUMN);
			op_orderedItems_table.setValueAt(null, row, OP_NAME_COLUMN);
			op_orderedItems_table.setValueAt(null, row, OP_DESCRIPTION_COLUMN);
			op_orderedItems_table.setValueAt(null, row, OP_UNIT_COLUMN);
			op_orderedItems_table.setValueAt(null, row, OP_QUANTITY_COLUMN);
			op_orderedItems_table.setValueAt(null, row, OP_PRICE_COLUMN);
			op_orderedItems_table.setValueAt(null, row, OP_SUBTOTAL_COLUMN);
			//TODO: pricegroup
			row++;
			if ((Integer) this.op_orderedItems_table.getValueAt(row,
					OP_ID_COLUMN) == 0) {
				flag = false;
			}
		}

		this.op_total_field.setText("0");
		//		}
	}

	private void clear_modifyItems_itemList_table() {
		//TODO: get this to work
		//		if (modifyItems_itemList_table.getModel().getRowCount() != DEFAULT_ROW_SIZE) {
		//			modifyItems_itemList_table.setModel(DEFAULT_MI_TABLE);
		//		} else {
		boolean flag = true;
		int row = 0;
		System.out.println("ran: clear_modifyItems_itemList_table");
		while (flag) {
			System.out.println("row:" + row);
			modifyItems_itemList_table.setValueAt(0, row, MI_ID_COLUMN);
			modifyItems_itemList_table.setValueAt(null, row, MI_NAME_COLUMN);
			modifyItems_itemList_table.setValueAt(null, row,
					MI_DESCRIPTION_COLUMN);
			modifyItems_itemList_table
					.setValueAt(null, row, MI_QUANTITY_COLUMN);
			modifyItems_itemList_table.setValueAt(null, row, MI_UNIT_COLUMN);
			modifyItems_itemList_table.setValueAt(null, row,
					MI_UNITPRICE_COLUMN);
			modifyItems_itemList_table.setValueAt(null, row, MI_AMOUNT_COLUMN);

			row++;
			if ((Integer) this.modifyItems_itemList_table.getValueAt(row,
					MI_ID_COLUMN) == 0) {
				flag = false;
			}
		}
		//		}
	}

	private boolean verify_modifyItems_Quantity_field() {
		try {
			int i = Integer.parseInt(modifyItems_Quantity_field.getText());
			if (i < 0) {
				modifyLabel_errorMessageLabel
						.setText("No negative numbers in Quantity box please");
				return false;
			}
			modifyLabel_errorMessageLabel.setText("");
			return true;
		} catch (NumberFormatException e) {
			modifyLabel_errorMessageLabel
					.setText("Please enter numbers in quantity field");
			return false;
		}

	}

	//returns -1 on error
	//returns the index of the next empty line
	//adds more rows when we get near the end of the table
	private int find_next_empty_line_in_op_orderedItems_table() {
		boolean flag = true;
		int i = 0;
		while (flag) {
			if ((Integer) this.op_orderedItems_table
					.getValueAt(i, OP_ID_COLUMN) == 0) {
				// Means we're near the end so we need to add more
				if (i == op_orderedItems_table.getModel().getRowCount() - 1) {
					this.addRowsToOP(DEFAULT_ADD_SIZE);
				}
				flag = false;
				return i;
			}
			i++;
		}
		return -1;
	}

	// Returns the number of rows currently in op_orderedItems_table
	private int getRowSizeOfOP() {
		return op_orderedItems_table.getModel().getRowCount();
	}

	// Returns the number of rows currently in modifyItems_itemList_table
	private int getRowSizeOfMI() {
		return modifyItems_itemList_table.getModel().getRowCount();
	}

	private boolean validate_Quantity_Column_in_modifyItems_itemList_table() {
		System.out
				.println("validate_Quantity_Column_in_modifyItems_itemList_table()");
		boolean flag = true;
		int row = 0;
		while ((Integer) this.modifyItems_itemList_table.getValueAt(row,
				MI_ID_COLUMN) != 0) {
			System.out.println("This is our row value: " + row);
			int z = (Integer) this.modifyItems_itemList_table.getValueAt(row,
					MI_QUANTITY_COLUMN);
			System.out.println("This is our 'z' value: " + z);

			if (z < 0) {
				this.modifyLabel_errorMessageLabel
						.setText("ERROR: failed due to a negative quantity");
				return false;
			}

			row++;
		}
		return true;
	}

	//searches the ModifyItem table to find if there exists an item
	//with a given id and if finds it returns it's unit. else returns empty string
	public String get_Unit_from_ModifyItem_table(int itemID/*, String PriceSheet*/) {//TODO: when PriceSheet is implemented this should support it
		boolean flag = true;
		int i = 0;
		while (flag) {

			int curItemID = (Integer) this.modifyItems_itemList_table
					.getValueAt(i, MI_ID_COLUMN);

			if (curItemID == itemID) {
				/*

				String curPriceSheet = (String)this.modifyItems_itemList_table.getValueAt(i, MI_PRICEGROUP_COLUMN);
				if(curPriceSheet.equals(PriceSheet))
				{

				 */
				return (String) this.modifyItems_itemList_table.getValueAt(i,
						MI_UNIT_COLUMN);
				/*

				}

				 */
			}
			i++;
			if (curItemID == 0) {
				return "";
			}

		}
		return "";
	}

	//returns -1 on error
	//returns the index of the next empty line
	//Increases the size of the table if we're almost out of space
	private int find_next_empty_line_index_in_modifyItems_itemList() {
		boolean flag = true;
		int i = 0;
		while (flag) {
			if ((Integer) this.modifyItems_itemList_table.getValueAt(i,
					MI_ID_COLUMN) == 0) {
				// Means we're almost out of rows and need to add more
				if (i == modifyItems_itemList_table.getModel().getRowCount() - 1) {
					this.addRowsToMI(DEFAULT_ADD_SIZE);
				}
				flag = false;
				return i;
			}
			i++;
		}
		return -1;
	}

	// Fills out customer related fields in the Order screen
	private void fill_Order_Screen() {
		int custID = Integer.parseInt(op_soldToCustID_field.getText());
		// custIndex = the customer's index in the Customers array in the mediator
		int custIndex = MEDIATOR.getCustomerListNumber(custID);

		op_shipToName_field.setText(MEDIATOR.getCustomerName(custIndex));
		op_shipToAddress_field1
				.setText(MEDIATOR.getCustomerAddress1(custIndex));
		op_shipToAddress_field2
				.setText(MEDIATOR.getCustomerAddress2(custIndex));
		op_shipToCity_field.setText(MEDIATOR.getCustomerCity(custIndex));
		op_shipToState_field.setText(MEDIATOR.getCustomerState(custIndex));
		op_directions_field.setText(MEDIATOR.getCustomerDirections(custIndex));
		op_salespersonCode_field.setText(MEDIATOR
				.getCustomerSalesperson(custIndex));
		op_foreman_field.setText(MEDIATOR.getCustomerForeman(custIndex));

		// fills in the price sheet combobox
		this.fillPriceSheetComboboxInOP();
	}

	// This method fills the price sheet combobox with all price sheets
	// The price sheet selected in customer sheet is the initial selected price sheet
	private void fillPriceSheetComboboxInOP() {
		int custIndex = MEDIATOR.getCustomerEditListNumber(Integer
				.parseInt(this.op_soldToCustID_field.getText()));

		op_priceSheet_combobox.removeAllItems();

		// Adds all current price sheets to the combobox
		ArrayList<Pricesheets> newPriceSheetList = MEDIATOR
				.getEditPriceSheets();
		for (int i = 0; i < newPriceSheetList.size(); i++) {
			op_priceSheet_combobox.addItem(newPriceSheetList.get(i)
					.getPriceSheetName());
		}

		// Sets the Customer's default price sheet as the selected price sheet
		// Updates the Price Sheet Template list and selects the appropriate price sheet
		String priceSheet = MEDIATOR
				.getCustomerEditPriceSheetContact(custIndex);
		for (int i = 0; i < newPriceSheetList.size(); i++) {
			if (priceSheet == newPriceSheetList.get(i).getPriceSheetName()) {
				op_priceSheet_combobox.setSelectedIndex(i);
			}
		}
	}

	// This method fills the price sheet combobox with all price sheets
	// The price sheet selected in customer sheet is the initial selected price sheet
	private void fillPriceSheetComboboxInMI() {
		int custIndex = MEDIATOR.getCustomerEditListNumber(Integer
				.parseInt(this.op_soldToCustID_field.getText()));

		this.modifyItems_PriceSheetSelect_combobox.removeAllItems();

		// Adds all current price sheets to the combobox
		ArrayList<Pricesheets> newPriceSheetList = MEDIATOR
				.getEditPriceSheets();
		for (int i = 0; i < newPriceSheetList.size(); i++) {
			modifyItems_PriceSheetSelect_combobox.addItem(newPriceSheetList
					.get(i).getPriceSheetName());
		}

		// Sets the Customer's default price sheet as the selected price sheet
		// Updates the Price Sheet Template list and selects the appropriate price sheet
		String priceSheet = MEDIATOR
				.getCustomerEditPriceSheetContact(custIndex);
		for (int i = 0; i < newPriceSheetList.size(); i++) {
			if (priceSheet == newPriceSheetList.get(i).getPriceSheetName()) {
				modifyItems_PriceSheetSelect_combobox.setSelectedIndex(i);
			}
		}
	}

	private void modifyItems_itemID_combobox_populate() {
		boolean flag = true;
		int itemCount = this.modifyItems_ItemList_combobox.getItemCount();

		// Only try to populate the list if we have active items
		if (MEDIATOR.getActiveItemsListLength() != 0) {

			// check if it is filled
			// check if it is filled with new info
			// If itemCount > 1 means we're not at the default blank list
			// So therefore we need to check if it's the right amount of items
			if (itemCount > 1) {
				System.out.println("itemCount: " + itemCount);
				System.out.println("ItemLength: "
						+ MEDIATOR.getActiveItemsListLength());
				if (itemCount == MEDIATOR.getActiveItemsListLength()) {
					flag = false;
					System.out.println("repopulation skipped");
				}
			}

			//if no populate
			if (flag) {
				ArrayList<Items> _items = MEDIATOR.getActiveItemsList();
				modifyItems_ItemList_combobox.removeAllItems();
				for (int i = 0; i < _items.size(); i++) {
					modifyItems_ItemList_combobox.addItem(_items.get(i)
							.getItemName());
				}
			}
			//set focus on index 0
			modifyItems_ItemList_combobox.setSelectedIndex(0);
		}
		// Means we have no active items
		else {
			System.out.println("No active items!");
			System.out.println("Active an item to continue.");
		}
	}

	// Updates combobox drop-down list for order selection
	private void updateSelectOrderCombobox() {
		// Grabs cust ID to search for
		int id = Integer.parseInt(this.op_soldToCustID_field.getText());
		// Gets all orders from customer in the form "Order ID"
		String[] orders = MEDIATOR.findOrdersByCustID(id);

		// Clears the current list and adds 'Select an order...' to the top
		selectOrder_dialog_combobox.removeAllItems();
		selectOrder_dialog_combobox.addItem("Select an order...");
		// Adds all orders to the list
		for (int i = 0; i < orders.length; i++)
			selectOrder_dialog_combobox.addItem(orders[i]);
	}

	// Updates the combobox drop-down list accessed from order screen
	public void updateSelectCustomerComboboxInORDER() {

		// Clears the combobox
		selectCust_dialog_ORDER_combobox.removeAllItems();

		// Adds 'Select a customer...' to the top of the list
		selectCust_dialog_ORDER_combobox.addItem("Select a customer...");

		// Adds all the customers to the list
		String[] newCustList = MEDIATOR.getCustomerNames();
		for (int i = 0; i < newCustList.length; i++) {
			selectCust_dialog_ORDER_combobox.addItem(newCustList[i]);
		}

	}

	private void updateDriverCombobox() {
		String[] driverList = MEDIATOR.getDriverList();
		// Clears the combobox
		selectDriver_dialog_combobox.removeAllItems();
		// Adds 'Select a driver...' to the top of the list
		selectDriver_dialog_combobox.addItem("Select a driver...");
		// Adds all the customers to the list
		for (int i = 0; i < driverList.length; i++)
			selectDriver_dialog_combobox.addItem(driverList[i]);
	}

	public void setOrderIDField(String id) {
		op_orderID_field.setText(id);
	}

	public void showSelectCustDialog(boolean visible) {
		selectCust_dialog_ORDER.setVisible(visible);
	}

	public void displayNotification(String str) {
		//format string
		String finalStr = "";
		System.out.println("str.length: " + str.length() + " ::" + str);
		if (str.length() < 50) {
			System.out.println("passed");
			finalStr = str;
		} else {
			System.out.println("formatting:");
			finalStr = finalStr.concat("<html><p>");
			int processed = 0;
			boolean flag = true;

			while (flag) {
				int end_index = processed + 50;
				if (end_index > str.length()) {
					flag = false;
					end_index = str.length();
				}

				finalStr = finalStr.concat(str.substring(processed, end_index));

				finalStr = finalStr.concat("<p>");
				processed = end_index;
				System.out.println(processed + " : " + end_index + "::"
						+ finalStr);
			}

			finalStr = finalStr.concat("</html></p>");
			System.out.println(finalStr);

		}

		//display string
		// // this.notificationDialog.setVisible(true);  bug # 102  bug # 102
		notificationDialog.displayNotification(finalStr);
	}

	// Adds numToAdd rows to the bottom of op_orderedItems_table
	// This method is kept separate from below because we might add more columns later on
	private void addRowsToOP(int numToAdd) {
		//can't add < 1 rows, so we only do stuff if it's a viable numbers
		if (numToAdd > 0) {
			DefaultTableModel curModel = (DefaultTableModel) op_orderedItems_table
					.getModel();

			for (int i = 0; i < numToAdd; i++) {
				// Default values for each new row
				curModel.addRow(new Object[] { new Integer(0), null, null,
						null, null, null, null });
			}
			op_orderedItems_table.setModel(curModel);
		}
	}

	// Adds numToAdd rows to the bottom of modifyItems_itemList_table
	// This method is kept separate from above because we might add more columns later on
	private void addRowsToMI(int numToAdd) {
		if (numToAdd > 0) {
			DefaultTableModel curModel = (DefaultTableModel) modifyItems_itemList_table
					.getModel();

			for (int i = 0; i < numToAdd; i++) {
				// Default values for each new row
				curModel.addRow(new Object[] { new Integer(0), null, null,
						null, null, null, null });
			}
			modifyItems_itemList_table.setModel(curModel);
		}
	}

	// Sets up the screen to create a new order by changing all fields to their defaults
	public void setNewOrder() {
		op_orderID_field.setText("-1");
		op_driver_field.setText("Name");
		op_routeOrder_field.setText("Route order..."); //TODO: something?
		op_orderStatus_field.setText("Pending...");
		op_soldToCustID_field.setText("");
		op_shipToName_field.setText("");
		op_shipToAddress_field1.setText("");
		op_shipToAddress_field2.setText("");
		op_shipToCity_field.setText("");
		op_shipToState_field.setText("");
		op_notes_field.setText("");
		op_directions_field.setText("Directions...");
		op_numPrinted_field.setText("0");
		op_entryTime_field.setText("N/A");
		op_enteredBy_field.setText("Name");
		op_shipmentDate_field.setText("N/A");
		op_paymentTerms_field.setText("C.O.D."); //TODO: something?
		op_foreman_field.setText("Name");
		op_billToCustID_field.setText("");
		op_taxAreaCode_field.setText("TN SALES TAX"); //TODO: something?
		op_taxLiable_field.setText("N"); //TODO: something?

		// Enable all of the buttons that may have been disabled earlier
		op_modifyItems_button.setEnabled(true);
		op_processOrder_button2.setEnabled(true);
		op_createOrder_button2.setEnabled(true);

		//clean up the screen
		this.clear_modifyItems_itemList_table();
		this.clear_op_orderedItems_table();
	}

	// Return true if we can print the order
	// Returns false otherwise
	private boolean isValidOrder() {
		// This means an order hasn't been selected, so we return false
		if (this.op_orderID_field.getText().equals("-1")
				|| this.op_orderID_field.getText().equals("000000")) {
			return false;
		}

		// Otherwise it's a valid order
		return true;
	}

	public void printOrder(java.awt.event.ActionEvent evt) {
		//TODO
		// \t = tab
		// \n = new line

		// 1) Save the order
		// 2) Save values in the table to a String
		// 3) Set that string into a text area
		// 4) set componentToBePrinted = textArea
		// 5) call this.print();

		// If order hasn't been shipped we need to save the values before we print
		if (!op_orderStatus_field.getText().equals("Shipped")) {
			op_createOrder_buttonActionPerformed(evt);
			this.fill_Order_Table_in_op(Integer.parseInt(op_orderID_field
					.getText()));
		}

		// if it's a valid order, we print it, otherwise we show an error dialog
		if (this.isValidOrder()) {
			String order = "Order ID: " + this.op_orderID_field.getText()
					+ "\n";
			order += "Order status: " + this.op_orderStatus_field.getText()
					+ "\n";
			order += "Customer Name: " + this.op_shipToName_field.getText()
					+ "\n";
			order += "Customer ID: " + this.op_soldToCustID_field.getText()
					+ "\n";
			order += "Address: \t" + this.op_shipToAddress_field1.getText()
					+ "\n";
			order += "\t" + this.op_shipToAddress_field2.getText() + "\n";
			order += "\t" + this.op_shipToCity_field.getText() + ", ";
			order += this.op_shipToState_field.getText() + "\n";
			order += "Notes: " + this.op_notes_field.getText() + "\n";
			order += "Directions: " + this.op_directions_field.getText() + "\n";
			order += "Entered by " + this.op_enteredBy_field.getText();
			order += " on " + this.op_entryTime_field.getText() + "\n";
			if (this.op_orderStatus_field.getText().equals("Shipped")) {
				order += "Shipped on " + this.op_shipmentDate_field.getText()
						+ "\n";
			}

			order += ITEM_HEADER;

			int row = 0;
			while ((Integer) this.op_orderedItems_table.getValueAt(row,
					this.OP_ID_COLUMN) != 0) {
				// ID
				int ID = (Integer) op_orderedItems_table.getValueAt(row,
						this.OP_ID_COLUMN);
				order += ID + "\t";

				// Name
				String name = (String) op_orderedItems_table.getValueAt(row,
						this.OP_NAME_COLUMN);
				order += name;
				int tabs = MAX_TABS - (name.length() / TAB_LENGTH);
				for (int i = 0; i < tabs; i++) {
					order += "\t";
				}

				// Unit
				String unit1 = (String) op_orderedItems_table.getValueAt(row,
						this.OP_UNIT_COLUMN);
				order += unit1 + "\t";

				// Quantity
				Integer quantity = (Integer) op_orderedItems_table.getValueAt(
						row, this.OP_QUANTITY_COLUMN);
				order += quantity + "\t";

				// Item Price
				Float price1 = (Float) op_orderedItems_table.getValueAt(row,
						this.OP_PRICE_COLUMN);
				order += this.decimalPriceFormat.format(price1.doubleValue())
						+ "\t";

				// Sub-total
				Float price2 = (Float) op_orderedItems_table.getValueAt(row,
						this.OP_SUBTOTAL_COLUMN);
				order += this.decimalPriceFormat.format(price2.doubleValue())
						+ "\n";

				row++;
			}

			order += "\nTotal: $" + this.op_total_field.getText();

			this.ppd_preview_textarea.setText(order);
			componentToBePrinted = this.ppd_preview_textarea;

			// If I don't set the dialog visible it won't print
			// For some reason, this works...
			this.printPreview_dialog.setVisible(true);
			this.printPreview_dialog.setVisible(false);

			this.print();

			// Once done printing, close print_dialog
			this.print_dialog.setVisible(false);
		} else {
			this.print_dialog.setVisible(false);
			// this.notificationDialog.setVisible(true);  bug # 102
			notificationDialog
					.displayNotification("Please select an order before printing.");
		}
	}

	private Component componentToBePrinted;

	public void print() {
		PrinterJob printJob = PrinterJob.getPrinterJob();
		printJob.setPrintable(this);
		if (printJob.printDialog())
			try {
				System.out.println("Calling PrintJob.print()");
				printJob.print();
				System.out.println("End PrintJob.print()");
			} catch (PrinterException pe) {
				System.out.println("Error printing: " + pe);
			}
	}

	public int print(Graphics g, PageFormat pf, int pageIndex) {
		int response = NO_SUCH_PAGE;

		Graphics2D g2 = (Graphics2D) g;

		//  for faster printing, turn off double buffering
		disableDoubleBuffering(componentToBePrinted);

		Dimension d = componentToBePrinted.getSize(); //get size of document
		double panelWidth = d.width; //width in pixels
		double panelHeight = d.height; //height in pixels

		double pageHeight = pf.getImageableHeight(); //height of printer page
		double pageWidth = pf.getImageableWidth(); //width of printer page

		double scale = pageWidth / panelWidth;
		int totalNumPages = (int) Math.ceil(scale * panelHeight / pageHeight);

		//  make sure not print empty pages
		if (pageIndex >= totalNumPages) {
			response = NO_SUCH_PAGE;
		} else {

			//  shift Graphic to line up with beginning of print-imageable region
			g2.translate(pf.getImageableX(), pf.getImageableY());

			//  shift Graphic to line up with beginning of next page to print
			g2.translate(0f, -pageIndex * pageHeight);

			//  scale the page so the width fits...
			g2.scale(scale, scale);

			componentToBePrinted.paint(g2); //repaint the page for printing

			enableDoubleBuffering(componentToBePrinted);
			response = Printable.PAGE_EXISTS;
		}
		return response;
	}

	public static void disableDoubleBuffering(Component c) {
		RepaintManager currentManager = RepaintManager.currentManager(c);
		currentManager.setDoubleBufferingEnabled(false);
	}

	public static void enableDoubleBuffering(Component c) {
		RepaintManager currentManager = RepaintManager.currentManager(c);
		currentManager.setDoubleBufferingEnabled(true);
	}
}